0

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">
Qudus
  • 1,440
  • 2
  • 13
  • 22

2 Answers2

0

Setting rquireSSL to false in web.config fixed the issue.

<httpCookies requireSSL="false" />
Qudus
  • 1,440
  • 2
  • 13
  • 22
0

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

riffnl
  • 3,248
  • 1
  • 19
  • 32