0
votes

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.

1
I have not confirmed that this is a fix, but I did find one person who fixed the problem by doing this: Threading.Thread.CurrentPrincipal = HttpContext.Current.UserMatt Hudson

1 Answers

0
votes

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