Global.asax Login Redirection code
I just recently upgraded to Sitefinity v. 6.3.5000 and I have been using this code for Sitefinity Login Redirection for UnauthorizedAccess Errors for the last several releases of Sitefinity:
public
class
Global : System.Web.HttpApplication
protected
void
Application_Start(
object
sender, EventArgs e)
Bootstrapper.Initialized +=
new
EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
void
Bootstrapper_Initialized(
object
sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
EventHub.Subscribe<IUnauthorizedPageAccessEvent>(
new
Telerik.Sitefinity.Services.Events.SitefinityEventHandler<IUnauthorizedPageAccessEvent>(OnUnauthorizedAccess));
void
OnUnauthorizedAccess(IUnauthorizedPageAccessEvent unauthorizedEvent)
var url = unauthorizedEvent.Page.Url.TrimStart(
'~'
);
HttpContext.Current.Response.Redirect(
"~/Sitefinity/login?ReturnUrl="
+ url);
//if (unauthorizedEvent.Page.Title.Contains("pp"))
// unauthorizedEvent.HttpContext.Response.Redirect("~/p1");
//else
Hello Samir,
I believe that the described problem is caused by some of the changes introduced in version 6.3. All base interfaces related custom events are moved in Telerik.Sitefinity.Services.Events dll.
All base interfaces related custom events in Sitefinity are moved into this assembly. As a result, you can declare custom events without the need of referencing Telerik.Sitefinity assembly. You must add a reference to Telerik.Sitefinity.Services.Events.dll in each project that consumes or produces events, otherwise you will get a compile-time error.