Follow bellow code in global.asax
protected void Application_AcquireRequestState(object sender, EventArgs e)
{
try
{
string
lcReqPath = Request.Path.ToLower();
// Session is not stable in
AcquireRequestState - Use Current.Session instead.
System.Web.SessionState.HttpSessionState curSession = HttpContext.Current.Session;
if (lcReqPath != "/root/login.aspx"&&
(curSession == null || curSession["User_Type"] == null))
{
// Redirect nicely
Context.Server.ClearError();
Context.Response.AddHeader("Location", "../../root/Login.aspx");
Context.Response.TrySkipIisCustomErrors = true;
Context.Response.StatusCode = (int)System.Net.HttpStatusCode.Redirect;
// End now end the current request so we
dont leak.
Context.Response.Output.Close();
Context.Response.End();
return;
}
}
catch (Exception)
{
// todo: handle exceptions nicely!
}
}
Redirect to login screen if session is expired in Asp.net c# (Web Form)
Reviewed by Ashwani
on
November 30, 2018
Rating:

No comments:
Post a Comment