+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / ReturnUrl is missing with Forms Authentication

ReturnUrl is missing with Forms Authentication

3 posts, 0 answered
  1. Leo
    Leo avatar
    3 posts
    Registered:
    07 May 2014
    12 Dec 2014
    Link to this post

    Hello,

    I'm using Sitefinity 7.1 on IIS7 with Forms Authentication. And the issue I'm facing is that httpErrors always override my customErrors in web.config.

    Let's say, I want to redirect anonymous users to login page and I set up customErrors for this purpose in web.config. In this case I end up getting 401 - Unauthorized error from IIS7 when restricted page is being accessed by the anonymous user.

    If I set up httpErrors in web.config, the user is correctly redirected to login page, but the problem in this case is that ReturnUrl parameter is not appended, so I do not know where to redirect user upon authentication.

    This happens only on "front end" of the website. If anonymous user tries to access Sitefinity back end, the ReturnUrl is always appended, even if no any httpErrors and customErrors setup in web.config.

    I also tried to setup redirect from Global.asax file like in the snippet below, but with no luck

        void Application_Error(object sender, EventArgs e)
        {
            var currentPage = HttpContext.Current.Request.Url.ToString();       

           Exception ex = Server.GetLastError();       

           if (ex is HttpException)
            {            HttpException httpEx = ex as HttpException;           

                          if (httpEx.ErrorCode == 401 || httpEx.Message.ToLower().Contains("access is denied due to invalid credentials") || httpEx.Message.ToLower().Contains("you do not have permission to view this directory or page using the credentials that you supplied"))
                         {
                                 Response.Redirect("~/login?ReturnUrl=" + currentPage);
                                 Server.ClearError();
                          }      

              }       
        }

    Please let me know if anyone came across the same issue and if there is a resolution.

    Appreciate any suggestions.

    Thanks a lot.

  2. Pavel Benov
    Pavel Benov avatar
    341 posts
    Registered:
    14 Mar 2016
    17 Dec 2014
    Link to this post
    Hello Leo,

    You have been provided answers to your question in the support ticket you have opened. Feel free to share the solution with the community.

    Regards,
    Pavel Benov
    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
     
  3. Leo
    Leo avatar
    3 posts
    Registered:
    07 May 2014
    17 Dec 2014 in reply to Pavel Benov
    Link to this post
    Yes, this issue is resolved by setting FrontEndLoginPageUrl property in Sitefinity backend -> Administration -> Settings -> Advanced -> Project ->Default site
3 posts, 0 answered