ASP.NET MVC3 client side state management
-
22-04-2021 - |
Frage
I have 2 Views in my MVC3 application. One View creates a cookie via JavaScript, and I'm trying to access it in another View.But it shows up as 'undefined'. Why so? Also, I wanted to know if there are any client side state management options in ASP.NET MVC3 besides Cookies?
Lösung 2
I figured out a workaround (not exactly what I was looking for though) for the problem.I used the Session object to store my data and then retrieved the session in a string variable under @{ } block in my razor View. I then accessed the C# variable in my JS code.
Andere Tipps
You can use HTML5 local storage:
window.localStorage["test"] = "Hello World!";
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow