Files
ayanova7/source/MBI/Global.asax.cs
2018-06-29 19:47:36 +00:00

72 lines
2.4 KiB
C#

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Threading;
using CSLA.Security;
namespace AyaNovaMBI
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
}
protected void Application_PreSendRequestHeaders(Object o, EventArgs e)
{
if (Request.AcceptTypes != null)
{
if (Request.Url.OriginalString.EndsWith(".aspx"))
{
if (Response.ContentType == "text/html")
{
if (Array.IndexOf(Request.AcceptTypes, "application/xhtml+xml") > -1)
{
/*Might need the following as per: http://idunno.org/archive/2005/09/02/229.aspx
* &&
Response.StatusCode == 200 &&
!Response.IsRequestBeingRedirected
* */
Response.ContentType = "application/xhtml+xml";
Response.AddHeader("Vary", "Accept");
}
}
}
}
}
protected void Application_AcquireRequestState(object sender, EventArgs e)
{
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("default.aspx");//working on case 1346 kept getting errors about this which was previously 1.aspx which doesn't exist
}
}
}
}
}