Click here to Skip to main content
Licence 
First Posted 26 Oct 2004
Views 49,382
Bookmarked 26 times

Transfering session state between ASP and ASP.NET

By r@hu! | 26 Oct 2004
A simple way to share sessions between ASP and ASP.NET.
8 votes, 44.4%
1
4 votes, 22.2%
2
1 vote, 5.6%
3

4
5 votes, 27.8%
5
2.08/5 - 18 votes
μ 2.08, σa 3.01 [?]

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!



Canada Canada

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalhi ! This is very important question for me . Pinmembersoulgangdog23:10 21 Mar '11  
Generalnot a better solution PinmemberShyam0073:57 11 Dec '09  
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    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120209.1 | Last Updated 26 Oct 2004
Article Copyright 2004 by r@hu!
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid