|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionOne of the core aspects that classic ASP developers (including me) always deal with when building applications is handling state information. This task is made more difficult in Web applications because HTTP is, by its very nature, a stateless protocol that doesn’t remember anything about a user between requests. The problem with user sessions in ASPThe stateless nature of HTTP makes the inclusion of a mechanism to save application state between user requests a must—the server must be able to identify the same user across multiple requests. Classic ASP included a First, the 120-bit session ID used to identify the session is always stored as a cookie on the browser. So, if the security policy of a user's employer disallows cookies, the Second, the data associated with the session and accessed through the session ID is stored on the Web server that processed the initial request and started the session. As a result, the session data can’t be shared in a web farm scenario where multiple web servers are processing requests from multiple clients. Although programmatic techniques, and system software such as the Windows 2000 clustering services and Application Center 2000, can be configured to force a client to access the same web server for each request (referred to as “sticky IP”), the overhead and possible imbalance that this situation creates reduces scalability. ASP.NET’s improved model offers more alternatives.The ASP.NET session implementation addresses both of these weaknesses by allowing for "cookieless" sessions and off-server storage of session data. The ASP.NET session state module is configured declaratively in the Web.config file like so: <sessionState mode="InProc" cookieless="false" timeout="20" />
In this case, the mode attribute is set to http://my.website.com/(55mfgh55vgblurtywsityvjq)/education.aspx
The long alphanumeric string in parentheses is the session ID. The ASP.NET engine extracts the session ID from the query string and can then associate the user request with the appropriate session. In this way, cookies are not required, nor are hidden form fields. So, pages without forms can still participate in the session. As with ASP before it, session state management in ASP.NET requires overhead. So, if a particular page will not be accessing the ASP.NET offers three session management solutions. They are:
I am going to explain in detail about the new session management options with ASP.NET, especially SQLSEVER and STATESERVER. InProcThis is same as the conventional ASP session management. Session is stored in memory on the web server. StateServer session managementA second option, accomplished by setting the mode attribute to <sessionState mode="StateServer"
stateConnectionString="tcpip=myserver:42424" cookieless="false" timeout="20" />
In this case, the state service is running on a machine called myserver on port 42424, which is the default. At the server, the port can be changed by editing the Port value in the HKLM\SYSTEM\CurrentControlSet\Services\aspnet_state registry key. Obviously, using the state service has the advantages of process isolation and sharability across a web farm. However, if the state service is stopped, all session data is lost. In other words, the state service does not persistently store the data as SQL Server does; it simply holds it in memory. Session management with SQL ServerASP.NET also allows you to store session data on a database server by changing the mode attribute to <sessionState mode="SqlServer"
sqlConnectionString="data source=127.0.0.1;user id=sa; password="
cookieless="false" timeout="20" />
Once the SQL Server is configured, the application code should run identically to the Pros and cons of the three session management solutions in brief
Points of InterestWhen you are upgrading an ASP application to ASP.NET, some times you may have to deal with the situation where in we need to pass state information between an ASP page and ASP.NET form. One way of accomplishing this is using cookies. Since cookies are stored in client side, when the browser requests a page, the cookie information is automatically send as part of the browser request. Because of this a cookie can be created by an ASP application and read by ASP.NET application when the browser is redirected to that ASP.NET page. HistoryVersion 1.1.
|
||||||||||||||||||||||