As we know that we can store the session state in the SQL server. Practically This is very simple to use. For Your application if reliability is more important than performance, then SQLServer is a better option compared to InProc and State Server
In this case we can maintain the Application in one server and Session in another server. You can Find the default stored procedures provided by Dot net it self in the following Directory. There are two Scripts one for Installing the database and another Uninstalling the Database
c:\windows\Microsoft.Net\Framework\version\InstallSQLstate.sql
Just Execute the Script in Query analyzer and a new database will be created with the name "ASPState". If you open and see u can't find any tables. Open the database "Tempdb", which contains two tables namely
1. ASPStateTempApplications 2. ASPStateTempSessions
And also it contains some stored procedure for inserting and retrieving the data. Now, all we need to do, as ASP.NET takes care of everything else for us, is modify the web.config so that the ASP.Net application knows it should use SQLServer for session state management.
Consider the following example configuration in web.config file sessionState tag. Change the sqlConnectionString According to your settings.
mode="SQLServer" sqlConnectionString="data source=localhost;user id=sa;password=HemaKumar" cookieless="true" timeout="20" />
Now How Test the application ? Just Create one sample page called "Sample.aspx". In page Load Assign the following statements.
Session("User")="HemaKumar" session("Company")="Exira Software"
Just run the application Now. It works...........
Happy Programming...
REFERENCE: MSDN Documentation.
|
No responses found. Be the first to respond and make money from revenue sharing program.
|