More in this section

Forums / Developing with Sitefinity / Global.asax Login Redirection code

Global.asax Login Redirection code

2 posts, 0 answered
  1. Samir Vaidya
    Samir Vaidya avatar
    261 posts
    05 Feb 2005
    30 Jan 2014
    Link to this post
    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");

    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.

  2. Kaloyan
    Kaloyan avatar
    272 posts
    06 Feb 2017
    03 Feb 2014
    Link to this post
    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.

    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
2 posts, 0 answered