Sunday, March 31, 2013

Session state management in mvc4 razor



Here You will get the solution of following queries:
Ques: What is Session state in MVC4 Razor?
Ques: How to handle behavior of Session State in ASP .Net MVC4?
Ques: Define State management in MVC4 Razor.
Ques: Does Session works fine with Controllers in .Net MVC?

By default, Asp.Net MVC support session state. Session is used to store data values across requests. Whether you store some data values with in the session or not Asp.Net MVC must manage the session state for all the controllers in your application that is time consuming. Since, session is stored on server side and consumes server memory, hence it also affect your application performance.


Let us talk about 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:

                              SessionStateBehavior Enumeration's Value
Session state MVC4 Razor

Session management ASP .Net MVC4 Razor



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:
Session handling with Controllers in MVC4 Razor



0 comments:

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Powered by Code Imagine