简体   繁体   中英

Best way to maintain session state in MVC

I have a search bar with 4 cascading dropdowns on it, the user makes a selection then clicks search. When the user returns to the search page I want the previous selected values to still be displayed.

Any comments on the best way to save these selected values?

Any reason not to put them in the Querystring?

If you're thinking of session, try TempData first which will take care of disposing the session for you.

As mentioned elsewhere, cookies are okay, but not RESTful. With Querystring, a search can be bookmarked. Some notables use this approach (google and SO to name two)

如果可以进行临时保存,请使用Cookie。

Session is still available in ASP.NET MVC. Plus, its mockable now. Win-win.

这就是Session词典的用途:在页面加载之间存储导航值...

We use enterprise library caching application block:

http://msdn.microsoft.com/en-us/library/dd203099.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM