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:
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.