When you use ASP.NET's Form Authentication, a query string key would be passed to login page, which is named "ReturnUrl".
For example, if you're not logged in already and you want to see a secure page like http://www.example.com/securepage.aspx
, you would be redirected to:
http://www.example.com/login.aspx?ReturnUrl=securepage.aspx
(Or something like that, I'm not pretty sure about ReturnUrl value).
Now, Is there a way to change this ReturnUrl
name, to something like path
for example? Do we have a kind of configuration in web.config for that?
Add this key to the appSettings section of your web.config
<add key="aspnet:FormsAuthReturnUrlVar" value="path" />
Probably in the easy way you can't do this, because it's hardcoded constant inside of System.Web
assembly:
internal static string GetReturnUrl(bool useDefaultIfAbsent)
{
FormsAuthentication.Initialize();
HttpContext current = HttpContext.Current;
string str = current.Request.QueryString["ReturnUrl"];
// ....
}
But probably you can use some Url rewriting.
Also, check this post on SO: rewrite url. asp.net c#
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With