Raja Afrika of the Afrika 8
Sunday, December 22, 2024
 
Back to Raja's Blog

Raja's Blog
Not All Who Wander Are Lost

Sharing Session Information Between Classic ASP and .NET
Posted: Wednesday, February 25, 2009

This is a problem that has been plauging developers since the advent of .NET.


How do you share the session information between Classic ASP and ASP.NET? You would think that there was a simple solution but there is not. Solutions that I found on Google ranged all over the map from writting text files to using SQL Server as a session state provider. That seemed like overkill to me. Anyways without further ado, this is the solution I came up with:


Pass it all in the querystring

PROS:

Simple to implement

Effective


CONS:

Not secure

Only supports 1024 characters worth of data


Here's what I did:

- I created two files ClassicASPListener.asp and DOTNETListener.aspx

- Both pages take the same querystring variables

Verb: Send, Receive

Redir: The final destination of the page request

Session: contents of your session object


ClassicASPListner loops through all of the session information and builds the string: SESSIONVARIABLE=VALUE and appends the result to the Session querystring variable and redirects to the DOTNETListener page.


DOTNETListener picks apart the querystring passes the querystring values into session values and redirects to the destination page.


A sample of a URL request that would go from a Classic ASP page to a .NET page would look like the following


<%



Dim strURL

strURL = "verb=send,redir=MyDotNetPage.aspx"

Response.Redirect "ClassicASPListener.asp?" & strURL


%>


That's it! Now you are passing session information back and forth between your .NET and Classic ASP pages.


Feel free to forward any questions to my email address martin@martinwelch.net