how to check session upon start in masterpage or in global.asax

Posted by user572276 on Stack Overflow See other posts from Stack Overflow or by user572276
Published on 2011-01-12T06:26:16Z Indexed on 2011/01/12 6:54 UTC
Read the original article Hit count: 292

Filed under:
|
|
|

i am new in asp.net form authentication and sessions

i would like to know how to save session in masterpage or in global.asax and how to clear session

how to better handle session timeout by redirecting to a page

this is my web.config session settings

<sessionState mode="InProc" cookieless="false" timeout="1"></sessionState>

code in my masterpage

 if (Request.Url.AbsolutePath.EndsWith("SessionExpired.aspx", StringComparison.InvariantCultureIgnoreCase))
    {
        HtmlMeta meta = new HtmlMeta();
        meta.HttpEquiv = "Refresh";
        meta.Content = "7; URL=./Login.aspx";
        Page.Header.Controls.Add(meta);
    }
    else
        HttpContext.Current.Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60)) + "; Url=./Public/SessionExpired.aspx");

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET