Created
April 13, 2013 05:08
-
-
Save avisra/5377022 to your computer and use it in GitHub Desktop.
This snippet allows you to redirect users to a specific page when they try to access a page they are not authorized to access.
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
namespace SitefinityWebApp | |
{ | |
public class Global : System.Web.HttpApplication | |
{ | |
protected void Application_Start(object sender, EventArgs e) | |
{ | |
Bootstrapper.Initialized += new EventHandler<ExecutedEventArgs>(Bootstrapper_Initialized); | |
} | |
protected void Bootstrapper_Initialized(object sender, ExecutedEventArgs e) | |
{ | |
if (e.CommandName == "Bootstrapped") | |
{ | |
EventHub.Subscribe<IUnauthorizedPageAccessEvent>(new Telerik.Sitefinity.Services.Events.SitefinityEventHandler<IUnauthorizedPageAccessEvent>(OnUnauthorizedAccess)); | |
} | |
} | |
void OnUnauthorizedAccess(IUnauthorizedPageAccessEvent unauthorizedEvent) | |
{ | |
// If the current page requires authentication and the current user is not authorized - redirect to page of choice | |
unauthorizedEvent.HttpContext.Response.Redirect("~/login"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment