Last post Oct 02, 2013 05:25 PM by Mikesdotnetting
Oct 02, 2013 12:37 PM|mandrews1234|LINK
I recently converted a web forms site to an application and got friendly urls running. The issue I'm running into is with the membership provider. Normally, when you go to a page you need to be logged into, the site would take you to
Well, now it's going to Login?ReturnUrl=%2fadmin%2fAddScores
But the membership provider doesn't recognize the returnurl. I'm assuming that's because it has to be gotten with friendlyurl.segments as opposed to request.querystring.
I tried searching for how to fix this, but maybe I didn't have the right keywords. How do I set up my application so the membership provider knows it's using friendly urls?
Oct 02, 2013 03:03 PM|Mikesdotnetting|LINK
The query string is identical in both examples. What do you mean by "doesn't recognise the return url"? What happens?
Oct 02, 2013 03:15 PM|mandrews1234|LINK
So when you use plain old web forms and you want to read the GET data, it looks something like this.
In the code, you'd just pull that with Request.Querystring("foo")
However, now that I'm running the friendly urls, it takes away the aspx and writes them differnetly. Any code you have where you're posting get data you need to change it to something like login/foo/bar and then you get the with FriendlyUrl.Segment
Where Segment(1) is foo and segment(2) is bar.
So the membership provider is automatically redirecting to login?ReturnUrl=SomePlace. Since it's not working now, but still works on the web forms site, I'm assuming that's because I changed up the urls to be friendly and it can't read the query string like
it normally does. I kind of figured that there has to be a workaround for this.
Oct 02, 2013 03:34 PM|Mikesdotnetting|LINK
The query string is everything after the question mark. You can see in both cases that you posted earlier the value after the ? is identical. When you do Request.QueryString["returnUrl"], ASP.NET doesn't care what goes before the ?
Any code you have where you're posting get data you need to change it to something like login/foo/bar and then you get the with FriendlyUrl.Segment
That's not correct. There is no querystring in login/foo/bar. GET data will always go after a ?, which is controlled by HTTP, not ASP.NET.
Since it's not working now
What exactly happens now? Where is the user taken to once they have logged in?
Oct 02, 2013 04:09 PM|mandrews1234|LINK
The user gets taken nowhere. I'm new to the friendly url thing so I may be wrong on some stuff. All I can say is when I moved it to friendly urls, the redirecting after logging in quit working.
Oct 02, 2013 05:25 PM|Mikesdotnetting|LINK
I suspect some other change has taken place in your application. The change the Friendly Urls seems to be a red herring. You have already confirmed that the returnUrl value is present and is the same as it always was. Anything before the ? in the url is
irrelevant. Have you still got a call to
FormsAuthentication.RedirectFromLoginPage when someone authenticates successfully?