locked
HttpContext.Current.Session.Count = 0 but HttpContext.Current.User.IsAuthenticated RRS feed

  • Question

  • User2013774033 posted

    Hello

    I have started a new asp.net web site using vs2010.

    I have a master form, a connection form, a default form.

    In the masterform, I test the HttpContext.Current.User.IsAuthenticated in order to read the HttpContext.Current.Session variables.

    In the connection page, once the user is authenticated, I set the following:
    HttpContext.Current.Session["MYVAR"] = "MYVALUE";
    The HttpContext.Current.User.IsAuthenticated = TRUE at that point.
    If I close the web browser, and re-launch the application, in the masterform, HttpContext.Current.User.IsAuthenticated is still TRUE - however HttpContext.Current.Session.Count = 0 - the HttpContext.Current.Session["MYVAR"] = ""

    Any idea why? what am I missing. I would think since i'm still authenticated, the session variables would still be available.
    My web.config has <sessionState mode="InProc" timeout="30"></sessionState>

    Thank you

    Tuesday, July 19, 2011 9:22 AM

All replies

  • User-1359474226 posted

    Hi

    Are you using forms authentication or windows authentication. You must be using windows authenticaion for isAuthenticated to be true when you open the browser. 

    Session will be lost if the browser is closed.

    Thank You

    Tuesday, July 19, 2011 10:21 AM
  • User2013774033 posted

    Hi

    Are you using forms authentication or windows authentication. You must be using windows authenticaion for isAuthenticated to be true when you open the browser. 

    Session will be lost if the browser is closed.

    Thank You

    I'm using forms authentication.But when I first start the application HttpContext.Current.User.IsAuthenticated = false until I log in. It remains like that until the session times out.

    Tuesday, July 19, 2011 10:46 AM