skip to Main Content

I am running an ASP.NET 4.0 application and published it using plesk control panel.I have done the following.

1.i set session timeout in web.config file as:

<sessionState timeout="20000"/>
  1. I handled session variable in login controller like this:

Session["userId"] = lUser.userId;
Session["role"] = lUser.userType;

into other controller, the code is like below:

if (Session["role"] == null)
{
     return RedirectToAction("Index", "Login");
}
 else if (Session["role"].ToString() == "Admin" || Session["role"].ToString() == "Super Admin")
{
    return View();
}

this code is ok in my local server but when published into real server using plesk control panel, it also ok for first time. but when i click the same menu second time it redirects to login page.

2

Answers


  1. Chosen as BEST ANSWER

    Instead of SessionState mode="InProc" use SessionState Mode="StateServer", but you'll need to make sure the server where you're hsoting the application has the StateServer active.

    <sessionState mode="StateServer" timeout="20000" cookieless="false" />
    

  2. Try adding:

    protected void Session_Start(Object sender, EventArgs e)
    {
        Session["init"] = 0;
    }
    

    to global.asax

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