Archive

Posts Tagged ‘ASP.net’

Data put in session is not available in ASP.net C#

January 17, 2011 Leave a comment

I have a login page, aftter entering login details,
the following code is executed:
Session[“userData”] = userData;
Response.Redirect(“welcome.aspx”);

while debugging i can see that in welcome.aspx Session is empty.

After searchinga lot on gooogle I found the solution:

If your write the session on the first hit then you should do

Response.Redirect(“welcome.aspx”, false);

Otherwise it wont write the whole response stream and the cookie might not have been written.

Categories: ASP.net C#, General Tags: ,