Click here to Skip to main content
6,596,602 members and growing! (20,033 online)
Email Password   helpLost your password?
Web Development » Session State » Sessions and Session State     Intermediate

Transfering session state between ASP and ASP.NET

By r@hu!

A simple way to share sessions between ASP and ASP.NET.
Windows, .NET 1.0, ASP, ASP.NET, Visual Studio, Dev
Posted:26 Oct 2004
Views:38,749
Bookmarked:23 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
18 votes for this article.
Popularity: 2.62 Rating: 2.08 out of 5
8 votes, 44.4%
1
4 votes, 22.2%
2
1 vote, 5.6%
3

4
5 votes, 27.8%
5

Problem

We need to transfer ASP session state to ASP.NET session state.

Things to consider

  • ASP and ASP.NET sessions are not shareable.
  • We would need something intermediate so that there is minimal rewriting of code.
  • We should be able to uniquely identify each client's session.

Solution

We can use database as the intermediate platform for transferring sessions. Create a table as:

ID Key Value
     

The ID should be unique. We can use Timestamp with IP address or GUID. We can store all session variables in this table as:

For i = 1 to Session.Contents.Count)-1
  strSql = Query to insert Session ID, Session.Contents.Key(i), 
            Session.Contents.Item(i)
  cmd.CommandText = strSql
  cmd.Execute
Next

Through this code, we can have all our session variables in database. In order to make this generic, we will write this code in a separate page, say Transfer.asp.

Asp page will contain now -> Response.Redirect(Transfer.asp?page=ASPXPage.aspx).

Transfer.asp will have Response.Redirect(ASPXPage.aspx?ID=xxxxx).

The aspx page will retrieve all the variables and put into the session in a similar way. We have passed the GUID as Query String. Not a good idea, I guess.

Hope you all find this useful.

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

About the Author

r@hu!


Member

Location: Canada Canada

Other popular Session State articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
GeneralThere are better solutions PinmemberMarc Campbell8:28 22 Nov '06  
GeneralWrong-headed PinmemberOakman14:14 2 Nov '04  
GeneralRe: Wrong-headed Pinsussbishoy Atef2:47 31 Mar '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 26 Oct 2004
Editor: Sumalatha K.R.
Copyright 2004 by r@hu!
Everything else Copyright © CodeProject, 1999-2009
Web22 | Advertise on the Code Project