ReturnUrl
is kind of ugly. I'd like to use redirect
instead. How can I specify the name of the parameter that should be used for forms authentication redirect URLs in conjunction with the [Authorize]
attribute? Or do I have to create an IAuthorizationFilter implementation? :(
Example:
[Authorize]
public class Tools : Controller
{
public ActionResult Index()
{
return View();
}
}
When a user who is not logged in visits http://example.com/tools, I'd like them to be redirected to http://example.com/account/logon?redirect=%2ftools
, instead of the default http://example.com/Account/LogOn?ReturnUrl=%2ftools
For the /account/logon part, I can modify my routes in Global.asax and change
<authentication mode="Forms">
<forms loginUrl="~/account/logon" timeout="2880" />
</authentication>
in web.config. But I don't know how to change the ReturnUrl parameter.
Add this key to the appSettings section of your web.config