Code Monkey home page Code Monkey logo

Comments (5)

brockallen avatar brockallen commented on July 19, 2024

Not sure. If you have a solution, then make a proposal and you can do a PR.

from cookietempdata.

jtheisen avatar jtheisen commented on July 19, 2024

It was the cookie size limit - not something more subtle as I thought before. I updated the description.

from cookietempdata.

brockallen avatar brockallen commented on July 19, 2024

Yea, well, I don't have much to offer then -- don't put so much data in there.

from cookietempdata.

jtheisen avatar jtheisen commented on July 19, 2024

In an example form I have with 10 fields, 4 validation errors and no actual input, I already get the Cookie to burst.

That means that in its current state, CookieTempData isn't really suited for using it for validation. Even with smaller forms the user input could easily still burst the cookie, and there is no error handling for those cases.

Also, according to some superficial research I did, the serialization appears to be wasteful.

For the case during development where my cookie burst, I made the following measurements (TempDataContent further below):

  • Json.NET unindented serialized length: 1522 (same as below without the indentation)
  • Json.NET unindented compressed length: 375

That's not too much, but the following is what CookieTempData gets from the tools it uses:

  • serializedWithBinaryFormatter size: 9630
  • compressed size: 3044
  • compressed and protected: 4141

And that's already blowing it.

Either SerializeWithBinaryFormatter is really wasteful or it serializes something that Json.NET skips. I haven't tested that.

Here's the actual content, just for plausibility (it's what Json.NET gets from the dictionary):

  "__MvcContrib_ValidationFailures__": {
    "id": {
      "Value": {
        "AttemptedValue": "2d474f3b-1a61-4c21-af92-f79c0a3edbd9",
        "Culture": "(Default)",
        "RawValue": [
          "2d474f3b-1a61-4c21-af92-f79c0a3edbd9"
        ]
      },
      "Errors": []
    },
    "PaymentMethod": {
      "Value": {
        "AttemptedValue": "InvoicePrePaid",
        "Culture": "de-DE",
        "RawValue": [
          "InvoicePrePaid"
        ]
      },
      "Errors": []
    },
    "CustomerName": {
      "Value": {
        "AttemptedValue": "",
        "Culture": "de-DE",
        "RawValue": [
          ""
        ]
      },
      "Errors": [
        {
          "Exception": null,
          "ErrorMessage": "The Customer name field is required."
        }
      ]
    },
    "ContactPersonName": {
      "Value": {
        "AttemptedValue": "",
        "Culture": "de-DE",
        "RawValue": [
          ""
        ]
      },
      "Errors": []
    },
    "PhoneNumber": {
      "Value": {
        "AttemptedValue": "",
        "Culture": "de-DE",
        "RawValue": [
          ""
        ]
      },
      "Errors": [
        {
          "Exception": null,
          "ErrorMessage": "The Phone number field is required."
        }
      ]
    },
    "EmailAddress": {
      "Value": {
        "AttemptedValue": "[email protected]",
        "Culture": "de-DE",
        "RawValue": [
          "[email protected]"
        ]
      },
      "Errors": []
    },
    "AddressLine1": {
      "Value": {
        "AttemptedValue": "",
        "Culture": "de-DE",
        "RawValue": [
          ""
        ]
      },
      "Errors": [
        {
          "Exception": null,
          "ErrorMessage": "The Address line 1 field is required."
        }
      ]
    },
    "AddressLine2": {
      "Value": {
        "AttemptedValue": "",
        "Culture": "de-DE",
        "RawValue": [
          ""
        ]
      },
      "Errors": [
        {
          "Exception": null,
          "ErrorMessage": "The Address line 2 field is required."
        }
      ]
    },
    "AddressLine3": {
      "Value": {
        "AttemptedValue": "",
        "Culture": "de-DE",
        "RawValue": [
          ""
        ]
      },
      "Errors": []
    },
    "Country": {
      "Value": {
        "AttemptedValue": "Deutschland",
        "Culture": "de-DE",
        "RawValue": [
          "Deutschland"
        ]
      },
      "Errors": []
    },
    "TaxNumber": {
      "Value": {
        "AttemptedValue": "",
        "Culture": "de-DE",
        "RawValue": [
          ""
        ]
      },
      "Errors": []
    }
  }

from cookietempdata.

jtheisen avatar jtheisen commented on July 19, 2024

I incorrectly assumed that using TempData to carry model state data is typical, which isn't the case.

Closing.

from cookietempdata.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.