ReturnUrl is missing with Forms Authentication

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

ReturnUrl is missing with Forms Authentication

All Replies

Posted by Community Admin on 12-Dec-2014 00:00

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.

Posted by Community Admin on 17-Dec-2014 00:00

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
 

Posted by Community Admin on 17-Dec-2014 00:00

Yes, this issue is resolved by setting FrontEndLoginPageUrl property in Sitefinity backend -> Administration -> Settings -> Advanced -> Project ->Default site

This thread is closed