Global.asax Login Redirection code

Posted by Community Admin on 04-Aug-2018 18:20

Global.asax Login Redirection code

All Replies

Posted by Community Admin on 30-Jan-2014 00:00

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
 
        
    

However, when I attempt to compile this code with the latest release of Sitefinity, I am getting an error message "Error 1 The type or namespace name 'SitefinityEventHandler' does not exist in the namespace 'Telerik.Sitefinity.Services.Events' (are you missing an assembly reference?)"

Where has this code moved to and what is the appropriate replacement code for the new assembly?

Please advise.

Thanks.

Posted by Community Admin on 03-Feb-2014 00:00

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.

In order to fix the problem you have to modify the references in your global.asax file.

Regards,
Kaloyan
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items

This thread is closed