response.redirect issue in ASP.Net

George2 picture George2 · May 9, 2011 · Viewed 9.4k times · Source

I am using ASP.Net + VSTS 2008 + .Net 3.5 + C# + IIS 7. I am wondering if at server side, I call response.redirect to another Url in the same web application, whether session will be continued or terminated?

e.g. if I set session variable foo to value "goo" in a.aspx, then in a.aspx I call response.redirect to b.aspx, whether in b.aspx I can 100% get the value for session variable foo to be "goo"? My confusion is I heard response.redirect will not 100% continue session, is that true?

thanks in advance, George

Answer

Town picture Town · May 9, 2011

You can use the overload for Response.Redirect that takes a bool as well, which does not end the response.

Response.Redirect("~/default.aspx", false)

Bertrand le Roy covers it here.