ASP/ASP.NET: Transferring Session State Between ASP and ASP.NET
Despite all of Microsoft's best efforts to make ASP and ASP.NET coexist effortlessly, one area
remains a stumbling block... session state. Fortunately the advantages of ASP.NET's upgraded session
state management far outweigh the inconvenience of not being able to pass "Classic" session information to .NET.
Unfortunately there is no simple solution; the most I can offer is an easy to implement workaround.
In trying to find a suitable resolution, I've come across two good options that are worth mentioning.
The first involves parsing the session information out to hidden form fields on a "Classic" intermediate
page and then submitting the page to a .NET intermediate page that loads the form fields into the session state.
This is a good, simple solution, however it doesn't work both ways. In .NET you cannot specify the page that
you submit to. Each page has to PostBack to itself.
The second option is probably closer to an actual solution than to a workaround. Billy Yuen at Microsoft
has developed an
effective solution.
The code is elegant, the integration appears to be seamless, but I
couldn't get it to work on my system (remember I said that there was no simple solution, not that there was
no solution at all). If this solution works for you, great! You won't need my code and you'll be happily
passing session information from "Classic" to .NET like it's going out of vogue, thanks for stopping by.
Ok, if you're still reading let me briefly describe the workaround I've created. It requires a database,
but it is not important which type of database (though the code is written for SQL Server). When a page
(source page) wants to redirect to another page (destination page) that uses a different version of ASP, it
calls an intermediate page. The source intermediate page takes each session variable and adds it to the
database along with a Globally Unique ID (GUID). Since "Classic" and .NET use different SessionID formats it
is not possible to use SessionID, hence the use of a GUID. The source intermediate page then passes the GUID
to the destination intermediate page through a Querystring variable. The destination intermediate page retrieves
the session information from the database, cleans up after itself, and then redirects to the destination page. It's
similar to the first workaround, but supports transferring state in both directions.