Back to Blog
Define session in asp.net7/22/2023 ![]() ![]() Step 1: Go To Start and from there go to "Run" and type "services.msc" as in the following: Now configure with the ASP.NET State Service. ![]() ![]() ![]() And the Session Variables are stored in an ASP.NET State service. This session state is totally managed by aspnet_state.exe. StateServer uses a stand-alone Windows Service that is independent on IIS and can also be run on a separate server. If the number of sessions is increased then the load of the server is also increased and the scalability could be an issue. In Session Mode the sessions are stored on the web server. So the InProc mode is dependent on the Web Server. If the client sends the request and the request goes to the server load balancer and then it sees which Web Server is needed to be used, for example if the Web Server1 is needed to be used then the request goes to WebServer1 and the session variable is stored in Web Server1 and if we refresh web form2 and again make a request to Web Form2 then the server load balancer sends the request to web server2 and the session variable is not stored in Web Server2 so the session variable is lost. Not Suitable for WebFarms and WebGardens: In a webFarm that the web application is deployed on the various web servers.Session data is lost when the worker process or application process is recycled.The following are the disadvantages of InProc mode: In this mode there is no need to serialize and deserialize the object for storage and retrieval of the data.Data is stored separately and the data is secure so it is suitable for web applications.It will perform fast because the session is kept on the web server within the ASP.NET Worker Process.Inproc session mode is very easy to implement, the only thing that is required is sessionState mode="InProc".The following are the advantages of the InProc mode: When we get the WebForm2 then if we end the task of aspnet_wp.exe from the Task Manager and then again reload the WebForm2 then you will get no output, which means that all the sessions are stored in a worker process and after closing the task the session will be lost. In Inproc Session mode the important point is:ฤก. I had explained by an example the use inproc session mode. Step 5: After adding the web form the following code is added to Web Form1.aspx. Step 4: Now right-click on the "Add" -> "New Item" -> "Web Form" and add the name of the web form and I had added 2 Web Form1.aspx and Web Form2.aspx. Step 2: Then Click on "New Project" -> "WEB" -> "ASP.NET Empty Web Application". Now here I am explaining sessions with an example. A session is one of the best techniques for State Management because it stores the data as client-based, in other words, the data is stored for every user separately and the data is secured also because it is on the server. It can support any type of object to be stored along with our own custom objects. A Session can store the value on the Server. So if we have a requirement to store the values of the controls and pass them into another web form then a State Management Technique is used. We all know that the web uses the HTTP protocol and the HTTP protocol is a stateless protocol in other words, when a client sends a request to the server, an instance of the page is created and the page is converted to HTML format and then the server provides the response and then the instance of the page and the value of the control are destroyed. ![]()
0 Comments
Read More
Leave a Reply. |