Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8756735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:08:38+00:00 2026-06-13T14:08:38+00:00

We have a website in classic asp that we are slowly migrating to ASP.NET

  • 0

We have a website in classic asp that we are slowly migrating to ASP.NET as necessary.

The problem of course is how classic asp and ASP.NET handle Sessions. After spending the last few hours researching the web, I found many articles, but not one that stood out over the others.

Is there a best practice for transferring session variables from and to classic asp and asp.net? Security is a must and any explanation with examples is much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:08:39+00:00Added an answer on June 13, 2026 at 2:08 pm

    A simple bridge to pass a single session variable from classic asp to .net serverside (hiding your sessionvalue from the client), would be this:

    • On the ASP end: An asp page to output your session, call it e.g. asp2netbridge.asp

      <%
      'Make sure it can be only called from local server '
      if (request.servervariables("LOCAL_ADDR") = request.servervariables("REMOTE_ADDR")) then
          if (Request.QueryString("sessVar") <> "") then
              response.write Session(Request.QueryString("sessVar"))
          end if
      end if
      %>
      
    • On the .net end, a remote call to that asp page. :

      private static string GetAspSession(string sessionValue)
       {
          HttpWebRequest _myRequest = (HttpWebRequest)WebRequest.Create(new Uri("http://yourdomain.com/asp2netbridge.asp?sessVar=" + sessionValue));
          _myRequest.ContentType = "text/html";
          _myRequest.Credentials = CredentialCache.DefaultCredentials;
          if (_myRequest.CookieContainer == null)
              _myRequest.CookieContainer = new CookieContainer();
          foreach (string cookieKey in HttpContext.Current.Request.Cookies.Keys)
          {
              ' it is absolutely necessary to pass the ASPSESSIONID cookie or you will start a new session ! '
              if (cookieKey.StartsWith("ASPSESSIONID")) {
                  HttpCookie cookie = HttpContext.Current.Request.Cookies[cookieKey.ToString()];
                  _myRequest.CookieContainer.Add(new Cookie(cookie.Name, cookie.Value, cookie.Path, string.IsNullOrEmpty(cookie.Domain)
                      ? HttpContext.Current.Request.Url.Host
                      : cookie.Domain));
              }
          }
          try
          {
              HttpWebResponse _myWebResponse = (HttpWebResponse)_myRequest.GetResponse();
      
              StreamReader sr = new StreamReader(_myWebResponse.GetResponseStream());
              return sr.ReadToEnd();
          }
          catch (WebException we)
          {
              return we.Message;
          }
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given: I have a website that includes both ASP.NET Web Forms and Classic ASP
I have an older classic ASP website that I am migrating over to IIS7.5.
I have a ASP.NET website that requires my App Pool be the Classic .Net
I have a web site that runs both classic ASP and ASP.NET Webforms. The
I have a classic ASP website (yes they still exist) that needs to call
I have a classic asp website that uses Session variables to store login state
We have a website that uses Classic ASP. Part of our release process substitutes
I have a shopping cart website running classic ASP that needs help during the
I currently have a website written in classic asp that runs multiple queries against
I have a website with a mix of ASP (classic) and ASP.NET pages. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.