Avatar of mlg74
mlg74 asked on

ReturnUrl from mobile Login page not working

I have a .net forms authentication with 2 login pages and ReturnUrl is not working on the 2nd on mobileLogin.aspx. Both the Login.aspx and the mobilLogin.aspx use a .net login control that are identical.

<authentication mode="Forms">
  <forms name="Login" loginUrl="login.aspx" protection="All" timeout="7200" path="/"/>
</authentication>

login.aspx redirect:
Response.Redirect("mobileLogin.aspx?ReturnUrl=" + Request.QueryString("ReturnUrl"))

Open in new window

For example this works, by redirecting to /admin/ folder
http://mysite.com/login.aspx?ReturnUrl=%2fadmin%2f

Open in new window

This does NOT work, it redirects to home page even after logging in,
http://mysite.com/mobilelogin.aspx?ReturnUrl=%2fadmin%2f

Open in new window

ASP.NETVisual Basic.NETC#

Avatar of undefined
Last Comment
mlg74

8/22/2022 - Mon
guru_sami

Is your login.aspx and mobilelogine.aspx using same code for authentication and redirect?
ASKER
mlg74

Yes exactly the same. It was just copy and pasted, then formatted it fr mobile diaplau
ASKER
mlg74

Display
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
guru_sami

Can you share the mobile login aspx and code-behind.
ASKER
mlg74

There is no code behind. I just dropped the control it's all built in.
ASKER CERTIFIED SOLUTION
guru_sami

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
mlg74

I will try and report back
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
mlg74

Thank you, this is how I did it:
 Protected Sub Login1_LoggedIn(sender As Object, e As EventArgs)
        Response.Redirect("mysite.com" + Request.QueryString("ReturnUrl"))
End Sub

And on the login control:
asp:Login ID="Login1" CreateUserText="create new account" CreateUserUrl="~/Register.aspx" runat="server" OnLoggedIn="Login1_LoggedIn">