In this article focus on state management in ASP.NET MVC.
What is state management ?
State Management is the process followed by developers in web application development to maintain state and page information over multiple request for the same or different pages.
Why do we need to manage state ?
The main way of communicating with internet HTTP. This HTTP protocol is stateless. It doesn't know anything about last request. Not having to remember user's last request web server can handle many concurrent users. ASP.NET MVC is designed with this stateless nature of HTTP. Because of this reason when we needs to remember user last request or user information we have to take the approach of state management.
How do we manage state in ASP.NET MVC ?
Client - Side
Cookies - small set of information passed to there server in every HTTP request. According to the requirement can set the expiration time for the cookies.
Query String - information appended to the URL. For secure the information can use HTTPS.
Hidden fields - Store value in the form hidden field. this value can use to send sever and operation of the client side.
Server - Side
Cache - cache object available for the all class within the application. This cache object can access through any user or page in the application domain.
Session - Information stored in the server and unique for the each user. There are mainly two method of session management which are InProc and OutProc. InProc use the web server memory and it comes with by default in IIS. In distributed application needs to use OutProc method. There are two method in OutProc way which are State server and SQL server. To use these methods in distribute application have to made changes to web config.
Profile - Information stored based on user name in a database. The profile is part of Membership and Roles provider.
No comments :
Post a Comment