web.config, Global.asax Session_Start (...) , , cookie, , :
public class Global:System.Web.HttpApplication
{
protected void Session_Start(object sender, EventArgs e)
{
if(Session.IsNewSession)
{
if (Request.Headers["Cookie"] != null)
{
if (Request.Headers["Cookie"].IndexOf("Web_App_Login_Cookie", StringComparison.OrdinalIgnoreCase) >= 0)
{
FormsAuthentication.SignOut();
Context.User = null;
Response.Redirect("~/logOn.aspx");
}
}
}
}
}
, - , OnInit (...) - , , - , .
public class SessionBasePage : System.Web.UI.Page
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (HttpContext.Current != null && HttpContext.Current.Session != null)
{
UserSession = HttpContext.Current.GetUserSession();
if (UserSession != null)
{
LoggedUserInfo = HttpContext.Current.GetLoggedUserInfo();
HttpContext.Current.UpdateLoggedUserInfo();
}
else { Response.Redirect("~/logOn.aspx", true); }
}
}
}
source
share