89 lines
2.3 KiB
Plaintext
89 lines
2.3 KiB
Plaintext
<%@ Application Language="C#" %>
|
|
<%@ Import Namespace="System.Threading" %>
|
|
<%@ Import Namespace="CSLA.Security" %>
|
|
|
|
<script runat="server">
|
|
|
|
|
|
|
|
void Application_Start(object sender, EventArgs e)
|
|
{
|
|
// Code that runs on application startup
|
|
|
|
}
|
|
|
|
void Application_End(object sender, EventArgs e)
|
|
{
|
|
// Code that runs on application shutdown
|
|
|
|
}
|
|
|
|
void Application_Error(object sender, EventArgs e)
|
|
{
|
|
// Code that runs when an unhandled error occurs
|
|
Exception ex = Server.GetLastError();
|
|
if (ex != null)
|
|
{
|
|
//crack the exception
|
|
while (ex.InnerException != null)
|
|
ex = ex.InnerException;
|
|
|
|
Application["LastException"] = ex;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
void Session_Start(object sender, EventArgs e)
|
|
{
|
|
// Code that runs when a new session is started
|
|
|
|
}
|
|
|
|
void Session_End(object sender, EventArgs e)
|
|
{
|
|
// Code that runs when a session ends.
|
|
// Note: The Session_End event is raised only when the sessionstate mode
|
|
// is set to InProc in the Web.config file. If session mode is set to StateServer
|
|
// or SQLServer, the event is not raised.
|
|
|
|
}
|
|
|
|
protected void SetPrincipal()
|
|
{
|
|
if (System.Web.HttpContext.Current.Session == null)
|
|
return;
|
|
|
|
|
|
if (System.Web.HttpContext.Current.Session["AyaNova-Principle"] != null)
|
|
{
|
|
Thread.CurrentPrincipal = (System.Security.Principal.IPrincipal)System.Web.HttpContext.Current.Session["AyaNova-Principle"];
|
|
HttpContext.Current.User = (System.Security.Principal.IPrincipal)System.Web.HttpContext.Current.Session["AyaNova-Principle"];
|
|
}
|
|
else
|
|
{
|
|
if (Thread.CurrentPrincipal.Identity.IsAuthenticated)
|
|
{
|
|
FormsAuthentication.SignOut();
|
|
Server.Transfer("Login.aspx");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
protected void Application_PostAuthenticateRequest(object sender, EventArgs e)
|
|
{
|
|
//SetPrincipal();
|
|
}
|
|
|
|
|
|
protected void Application_AcquireRequestState(object sender, EventArgs e)
|
|
{
|
|
|
|
SetPrincipal();
|
|
|
|
}
|
|
</script>
|