Session state can only be used when enableSessionState is set to true either in a configuration

后端 未结 12 934
[愿得一人]
[愿得一人] 2020-11-29 04:44

I am working on Asp.net MVC 2 app with c# by using vs 2010.I am having below mentioned error when I run my app locally under debug mode.

Error message image is as be

12条回答
  •  爱一瞬间的悲伤
    2020-11-29 04:59

    Did you enable the session state in the section as well?

     
           
     
    

    Or did you add this to the page?

     <%@Page enableSessionState="true"> 
    

    And did you verify that the ASP.NET Session State Manager Service service is running? In your screenshot it isn't. It's set to start-up mode Manual which requires you to start it every time you want to make use of it. To start it, highlight the service and click the green play button on the toolbar. To start it automatically, edit the properties and adjust the Start-up type.

    Or set the SessionState's mode property to InProc, so that the state service is not required.

     
          
     
    

    Check MSDN for all the options available to you with regards to storing data in the ASP.NET session state.


    Note: It's better to have your Controller fetch the value from the session and have it add the value to the Model for your page/control (or to the ViewBag), that way the View doesn't depend on the HttpSession and you can choose a different source for this item later with minimal code changes. Or even better, not use the session state at all. It can kill you performance when you're using a lot of async javascript calls.

提交回复
热议问题