I want to share session objects from Classic ASP to ASP.NET in our application during the development. I found so many articles in the internet regarding this, some of them are more confusing to me, then I plan to create a new one for my application. Here I am happy to share my code to all of my friends in CodeProject.
The logic behind this session transfer is
Asp Session Variables -> Store in the Database with GUID -> Redirect to the ASP.Net Page with GUID -> Get the Session information from the Database with the received GUID
Points to Remember
In this sample application I have used the following files:
In the "SampleAspPage.asp" file, I have created two session variables and stored the same in the Database. If we need to communicate database from the ASP application will required a DSN. So before using this we should need to create a DSN with your database settings and update it details to this file.
In the Default.aspx.cs file, we should need to update the database connection string details.
We have to create one table in your database with the following structure for storing the Session informations.
CREATE TABLE ASPSessionState
GUID CHAR(38), -- The Globally unique identifier
SessionKey VARCHAR(254), -- The Session value's "name"
SessionValue VARCHAR(254) -- The Session data
CREATE NONCLUSTERED INDEX idxSessionStateGUID
How to execute Sample Program
Unzip the "SessionSharing.zip" to your wwwroot folder and configure the virtual directory in IIS properly. Execute this application after setting the start page as "SampleAspPage.asp".
Happy Coding to all!