tags:

views:

84

answers:

3

I am redirecting from a classic ASP page to an ASP.Net page on a different webserver. The landing aspx page seems to start a new session after postback i.e. my session variables which are set when the page is first hit after the redirect, are being reset after a button on the page is clicked. How do I work around this? Thanks in advance.

+2  A: 

You might want to read "How to Share Session State Between Classic ASP and ASP.NET".

But you should know from start, there's no way to just pass the sessions between asp and asp.net using the session-object in both of them.

Read the above article and you'll know all about it!

Filip Ekberg
A: 

Microsoft has a page explaining how to share session data between classic ASP en ASP.NET. You can find it here

edosoft
Let me explain a bit more... I am not trying the share state. I redirect from ASP to an ASP.Net page on a different server (test.aspx). The test.aspx page creates a few session vars. When a button on that page is clicked causing a postback, the session vars are lost. This does not happen when I go directly to the test.aspx page without the redirection from the asp page.
yuben
Can you show some code? This might help.
edosoft
ASP Page: <% response.redirect("test.aspx?uid=hippo") %> ASP.Net Page: Page_Load if(Session["test"] != null) Response.Write(Session["test"].ToString()); if(!Page.IsPostBack) Session["test"] = Request.QueryString("uid"); Button_Click: Response.Write(Session["test"].ToString()); The Button_Click "event" throws a null reference exception.
yuben
One more thing - if I replace the asp page with an asp.net page still using the two different servers, it works.
yuben
I've tested this and I get no error. Using IIS 7.
edosoft
Thanks, I am using IIS6, so maybe I'll check if there is a configuration issue of some sort.
yuben
A: 

OK, I had a look at the HTTP headers being sent to the server in each of the two cases: when redirecting from ASP and from ASP.Net. I noticed that in the case of ASP.Net a cookie was being sent ASP.Net_SessionID. This was not being sent from the ASP page. I did some reading and found out that you can set ASP.Net to run cookieless - http://msdn.microsoft.com/en-us/library/aa479314.aspx. I added the

    sessionState cookieless="true"

to my web.config and all is well. Your assistance is much appreciated.

yuben