Question

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?

Était-ce utile?

La solution 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.

Autres conseils

You can use HTML5 local storage:

window.localStorage["test"] = "Hello World!";
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top