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?

Was it helpful?

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.

OTHER TIPS

You can use HTML5 local storage:

window.localStorage["test"] = "Hello World!";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top