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

Transfering session state between ASP and ASP.NET

By | 26 Oct 2004 | Article
A simple way to share sessions between ASP and ASP.NET.

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 . Pinmembersoulgangdog22:10 21 Mar '11  
Generalnot a better solution PinmemberShyam0072:57 11 Dec '09  
GeneralThere are better solutions PinmemberMarc Campbell7:28 22 Nov '06  
GeneralWrong-headed PinmemberOakman13:14 2 Nov '04  
GeneralRe: Wrong-headed Pinsussbishoy Atef1:47 31 Mar '05  
i have this problem now , i would like to send ASP form contents to ASP.net
so i can use Request.Form["xxxxx"] , the problem is that the ASP page contains dynamic fields so ican`t request it from the ASP.net page, so i decided to join this fields in one string and send it through session , but no sessions between asp and ASPX ,
 
solution :
i made a javascipt function combines all the data in one hidden textbox and requested this hiddden textbox from the other page,
 
<!--
function Submit1_onclick()
{
document.getElementById("TextArea").value =

document.getElementById("Text1").value +
document.getElementById("Text2").value;
}
 
//-->
</script>
 
hope it solves the problem
____________________
Bishoy Atef Armanios
EGYPT
Bishoy@gmx.net

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.120528.1 | Last Updated 26 Oct 2004
Article Copyright 2004 by r@hu!
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid