On authentication, the email of the user is retrieved and stored as session data like below
protected void Page_Load(object sender, EventArgs e)
{
string email = Request.Form["email"];
HttpContext.Current.Session["email"] = email;
Server.Transfer("Home.aspx");
}
The email is successfully stored but when I navigate to a new page and try to retrieve the session value like below. I see the session has been lost
var email = (string)Session["email"] ?? "";
I already enabled session state in web.config
<pages enableSessionState="true">
<sessionState timeout="20" mode="InProc">
2
Answers
Setting rquireSSL to false in web.config fixed the issue.
In asp.net application when use server.transfer its not work,because instead of use server.transfer use Response.Redirect("Home.aspx")
That’s why causing issue not getting session value in home page.
Also check this link hope will usefull for this
Server.Transfer causing Session exception