I am beginner to FriendlyUrl concept in asp.net. I want use ReturnUrl for login page. Can still use http://localhost:8080/login?ReturnUrl=/page
?
So once user logins in will be redirected to returnurl
I am beginner to FriendlyUrl concept in asp.net. I want use ReturnUrl for login page. Can still use http://localhost:8080/login?ReturnUrl=/page
?
So once user logins in will be redirected to returnurl
Yes this is still possible but probably not what you are expecting if i understand your question correctly. Your ReturnUrl is a Querystring parameter which the Friendlyurls plugin will leave intact, but Friendlyurl does not use this parameter on its own to do a redirect. That's something you will have to do.
The only thing you need to do in code is use this parameter to do a Response.Redirect
with after your login code has completed and succesfully authenticated your user. you can leave the slash out so it gets easier. Just do this in your code behind:
VB
If Request.QueryString("ReturnUrl") <> Nothing Then
Response.Redirect(Request.QueryString("ReturnUrl"))
Else
// Do your normal redirect here
End If
C#
if (Request.QueryString["ReturnUrl"] != "" &&
Request.QueryString["ReturnUrl"] != null)
{
Response.Redirect(Request.QueryString["ReturnUrl"]);
}
else
{
// Do your normal redirect here
}
This way your Code will check if the ReturnUrl is available and if so use it to do a redirect, or use your default redirect if available.
Of course you have to think of your folder structure of your project when redirecting; if your page to redirect to is in a sub folder in your project, the subfolder needs to be added to the redirect location like this: ReturnUrl=SubfolderName/Page
. This is always important, even when you are using FriendlyUrls and Distinct page names.
I had the same problem where the FriendlyUrls where not working as an ReturnUrl, the solution I've used is overriding the ReturnUrl like below. An extra option would be with Jeroens code to use the ReturnUrl.
Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn
'overrides ReturnUrl page parameter
Response.Redirect(Login1.DestinationPageUrl)
End Sub