Page.EnableSessionState equivalent in ASP.NET MVC

前端 未结 2 802
梦谈多话
梦谈多话 2020-12-31 06:19

With ASP.NET WebForms it is possible to set the session state mode in the page directive:

<%@ Page EnableSessionState=\"true|false|ReadOnly\" %>
         


        
2条回答
  •  一向
    一向 (楼主)
    2020-12-31 06:59

    The ASP.NET MVC 3 equivalent to this appears to be the SessionState attribute, which you apply at the controller level - e.g.

    [SessionState(SessionStateBehavior.ReadOnly)]
    

    See http://msdn.microsoft.com/en-us/library/system.web.mvc.sessionstateattribute.aspx for more info.

    Thanks to https://stackoverflow.com/a/4235006/372926

提交回复
热议问题