ETFairfax
ETFairfax

Reputation: 3814

ASP.NET: Security Exception not being caught in global.asax

I have (pretty much) the following code in my protected void Application_Error(object sender, EventArgs e) method in Global.asax....

Exception ex = Server.GetLastError();

if (ex is System.Security.SecurityException)

Response.Redirect("Logon.aspx");

else

Response.Redirect("ErrorPage.aspx");

If I navigate to a page before I log on the exception is caught and I am redirected to Login.aspx as I would expect. However, this is only working when debugging using VS on my local machine.

When uploaded to the live environment, the exception is not caught and the user is presented with "Security Exception - Request for principal permission failed."

Any ideas what the problem could be? I'm guessing that is an IIS thing - any thoughts?

Thanks,

ETFairfax.

Upvotes: 0

Views: 751

Answers (1)

Matt Hudson
Matt Hudson

Reputation: 7348

Try Threading.Thread.CurrentPrincipal = HttpContext.Current.User

Upvotes: 0

Related Questions