skip to Main Content

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


  1. Chosen as BEST ANSWER

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

    <httpCookies requireSSL="false" />
    

  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search