I would like to be able to use the same Session variable when transferring to another app.
Does Response.Redirect use the same session or start a new one?
I am using c#, aspnet 3.5
I would like to be able to use the same Session variable when transferring to another app.
Does Response.Redirect use the same session or start a new one?
I am using c#, aspnet 3.5
Response.Redirect
does nothing with the session. The session is tied (typically) to a cookie associated with the URI of the web app. If you switch to another web app on another server or a separate URI, the session will not carry over even if you managed to preserve the cookie.
Can you clarify what problem it is you're trying to solve?
It uses the same session.
EDIT: That is assuming the new URL would have used the same session anyway.
Response.Redirect
sends an Http Response to the browser with a status code of 302 Found
and a header Location: {redirection-url}
.
The browser receives this response, and knows to send a new request to the {redirection-url}
when it receives a response with a status code of 302 Found
.
That's all that happens.
Response.Redirect
does not start or stop or have anything to do with any sessions.
If you are trying to access session variables from a different app then thats not going to work as far as I remember. Session variables are only valid within the one app.
If you are trying to just redirect to another folder within the same app then the session variables are available.
If the two apps are indeed separate you could look at storing the session objects in a database and passing the sessionID to the new app using either a POST or a url parameter, however, neither of these are very secure and leave the app open to hacking without proper care being taken to ensure the users identity.