Click here to Skip to main content
15,884,472 members
Articles / Web Development / ASP.NET
Article

Share the session objects from Classic ASP to ASP.NET

Rate me:
Please Sign up or sign in to vote.
1.23/5 (8 votes)
21 Aug 20071 min read 24.9K   143   12   4
This article simply describes how to share the session objects from Classic ASP to ASP.NET

Introduction

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:

  • SampleAspPage.asp
  • Default.aspx
  • Default.aspx.cs

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
)
GO
CREATE NONCLUSTERED INDEX idxSessionStateGUID
ON ASPSessionState
(
 GUID
)
GO

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!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Team Leader
India India
I am Rajesh Babu, currently working for Nous Infosystems, Bangalore. I have 6 plus years experience in Microsoft Technologies.

Comments and Discussions

 
GeneralASPSessionState maintenance Pin
Tchaud017-Apr-09 9:13
Tchaud017-Apr-09 9:13 
QuestionNon-Internet Explorer Browsers Pin
andresb32130-Sep-07 7:46
andresb32130-Sep-07 7:46 
GeneralThis code looks the same ... Pin
Bruno Capuano4-Sep-07 22:21
Bruno Capuano4-Sep-07 22:21 
as this one http://www.asp101.com/articles/sidney/sharingsessionstate/default.asp[^]

are you using this code ? please put a link to the original one

Bye from Spain
El Bruno

GeneralGood Article Pin
rilov21-Aug-07 10:42
rilov21-Aug-07 10:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.