Created
November 11, 2014 13:22
-
-
Save sitefinitysteve/9d22b8ea8e0856e5f465 to your computer and use it in GitHub Desktop.
Application_Error to handle document passthrough
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void Application_Error() | |
{ | |
//Sitefinity Logger should send to raygun now | |
var exception = Server.GetLastError(); | |
//Send document requests over to login | |
if(exception.Message.Contains("You are not authorized to 'View document'") || exception.Message.Contains("You are not authorized to 'View image'")){ | |
if (!ClaimsManager.GetCurrentIdentity().IsAuthenticated) | |
{ | |
//If user is anonymous, send them to the login | |
var defaultUrl = Config.Get<ProjectConfig>().DefaultSite.FrontEndLoginPageUrl; | |
//Clear errors | |
HttpContext.Current.ClearError(); | |
//Send the user to your loginpage | |
Response.Redirect("{0}?ReturnUrl=/Download.aspx%3ffile={1}".Arrange(defaultUrl, HttpContext.Current.Request.Url.AbsoluteUri.Replace("?", "%3f"))); | |
} | |
} | |
//Other error processing like Raygun.io or whatever... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment