Comments (5)
Not sure. If you have a solution, then make a proposal and you can do a PR.
from cookietempdata.
It was the cookie size limit - not something more subtle as I thought before. I updated the description.
from cookietempdata.
Yea, well, I don't have much to offer then -- don't put so much data in there.
from cookietempdata.
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.
I incorrectly assumed that using TempData to carry model state data is typical, which isn't the case.
Closing.
from cookietempdata.
Related Issues (15)
- Circular references.. HOT 2
- Problem with Model State HOT 5
- Problem With CookieTempData HOT 6
- Handle the case when an app tries to store so many data tha a cookie size isn't enough for it HOT 2
- Error occurred during a cryptographic operation. HOT 23
- TempData on SignOut HOT 3
- Error occurred during a cryptographic operation HOT 4
- Public CookieTempDataControllerFactory HOT 8
- No way to change the serialization HOT 7
- The SessionStateTempDataProvider class requires session state to be enabled : Error on production server HOT 1
- 'Invalid length for a Base-64 char array or string.' when using cookie tempdata provider HOT 3
- Move dependencies to NuGet packages HOT 8
- Transient CryptographicException in LoginExternal HOT 1
- test
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cookietempdata.