Session Less Controller
If some of the controllers of your Asp.Net MVC application are not using session state features, you can disable session for those controller and can gain slight performance improvement of your application. You can simplify session state for your application by using available options for session state.In Asp.Net MVC4, SessionState attribute provides you more control over the behavior of session-state by specifying the value of SessionStateBehavior enumeration as shown below:
Value Description
Default The default Asp.Net behavior is used to determine the session state behavior.
Disabled Session state is disabled entirely.
ReadOnly Read-only session state behavior is enabled.
Required Full read-write session state behavior is enabled.
In Asp.Net MVC, TempData use session state for storing the data values across requests. Hence, when you will disabled the session state for the controller, it will throw the exception as shown below:
No comments:
Post a Comment