More in this section
Forums / Developing with Sitefinity / OnUnauthorizedAccess method is not being called when unauthorized access happens

OnUnauthorizedAccess method is not being called when unauthorized access happens

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. kaarthick
    kaarthick avatar
    1 posts
    04 Jul 2016
    12 Dec 2016
    Link to this post

    My MVC application is configured to have both admin login(backend users) and membership provider(for normal users),

    When normal user login, they have to be restricted to backend sitefinity which happens now.

    Now i need to set custom error page showing them they arent allowed to access the backend.

    I followed this link -

     to redirect the user to custom error view ~/Error/NotFound.


    My Global.asax file is as follows,

    protected void Application_Start(object sender, EventArgs e)
                //subscribe to Bootstrapper.Initialized event
                Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);

     void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
                if (e.CommandName == "Bootstrapped")
                    //use UnauthorizedPageAccessEvent
                    EventHub.Subscribe<IUnauthorizedPageAccessEvent>(new Telerik.Sitefinity.Services.Events.SitefinityEventHandler<IUnauthorizedPageAccessEvent>(OnUnauthorizedAccess));

            void OnUnauthorizedAccess(IUnauthorizedPageAccessEvent unauthorizedEvent)
                var url = unauthorizedEvent.Page.Url.TrimStart('~');
                //for this specific page redirect to CustomerLoginPage
                if (unauthorizedEvent.Page.Title.Contains("needadminrights"))



    I had kept break points and it hits application start() and  Bootstrapper_Initialized(). When normal user tries to access localhost:yyyyy/sitefinity after authenticated , it does not hit OnUnauthorizedAccess() method nor invokes unauthorizedEvent.

    I expect the normal user is unauthorized to access localhost/sitefinity and should be taken to Error view ~\Error\NotFound.




  2. Brian
    Brian avatar
    26 posts
    12 Jun 2015
    28 Aug 2017 in reply to kaarthick
    Link to this post
    Did you ever get this resolved?
2 posts, 0 answered