0

I have a web app where user is required to authenticate to view certain pages.

Authentication is forced in web.config by doing a re-direct to Login.aspx

When user is on the Login.aspx page the URL is in the following format:

http://localhost:51101/Login.aspx?ReturnUrl=%2fSupport.aspx

After user authorizes I'd expect ASP.Net to re-direct the user to Support.aspx page, but this doesn't happen.

Support.aspx is not the only page that requires authentication, therefore I can't do a re-direct in a code-behind file.

Is there a web.config setting that I'm missing out?

Thank you

Edit:

Basic authentication logic

            if (!Membership.ValidateUser(user, password))
            {
                errorId.Text = "Incorrect username or password";
            }
            else
            {
                FormsAuthentication.SetAuthCookie(user, true);  
                // I can add a re-direct here, but it won't do the job since there are multiple pages that require authentication
            }
3
  • Perhaps the login page is also responsible for logging the user out and is doing so just after the user logs in. Commented Feb 8, 2011 at 16:29
  • So where do they get redirected upon successful login? Commented Feb 8, 2011 at 16:33
  • Does login.aspx have any code? If so, please show us. Commented Feb 8, 2011 at 16:35

2 Answers 2

3

Are you using Forms Authentication? If so, you will need to call the

FormsAuthentication.RedirectFromLoginPage()

method in Login.aspx

Reference

Sign up to request clarification or add additional context in comments.

Comments

0

I don't think there is a way to have ASP.NET to handle that for you. You might have to look for "returnUrl" in the querystring manually in Global.asax Session_Start() and redirect to the value if the user is logged in.

Edit: I'm wrong. Thanks to John Pick for correcting me.

2 Comments

Normally ASP.NET does handle the ReturnUrl automatically.
Correction: Normally <asp:Login> handles ReturnUrl automatically. The current issue doesn't involve <asp:Login>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.