Search code examples
asp.netasp-classicasp.net-session

Classic ASP to ASP.Net one-off session data copy


We have an extensive classic ASP site, and we're looking to upgrade to ASP .Net (most probably the latest version). Obviously upgrading all the pages at once would be a leviathan task, so we're only looking to write new pages (and page rewrites) in ASP .Net at first.

There are two obstacles to doing so:

  1. I have no idea how to access classic ASP session data in ASP .Net. This would only have to be set up once, as it is never modified by any page other than the login page. I'd prefer to have to make minimal changes to the classic ASP login page, but that's only a small preference.

  2. The ASP and ASP .Net sessions would have to timeout at the same time, to keep the version difference seamless.

Could anyone offer any help, please?

Thanks in advance.


Solution

  • We faced the same task (not fun). Since Asp.Net session and Asp session can't be shared, we used a combination of methods, each appropriate to the situation.

    • In some cases, we used cookies instead of session.
    • In others, we set up automatically posting forms so that if a user's session information was set in a classic ASP page, after the session info was set, we redirected to an Asp.Net page that read in query string parameters and used those to set the same session variables for Asp.Net. Then once the Asp.Net page set the same variables, that page did a redirect to whatever page the original login page previously pointed to. The same worked in reverse.

    So, in the second scenario, an example flow would have changed from:

    User tries to access some protected content page -> redirected to login page -> logs in -> session info set based on login success -> redirected back to content page.

    to

    User tries to access some protected content page -> redirected to login page -> logs in -> session info set based on login success -> redirected to a .net page, passing along login credentials, etc. -> aspx page sets session info and then immediately redirects back to content page.

    We knew it was a hack, but it worked in the short-term until we could get the sites all converted.