【发布时间】:2015-12-11 18:48:27
【问题描述】:
ReturnUrl 有点丑。我想改用redirect。如何指定应该用于表单身份验证重定向 URL 的参数名称以及 [Authorize] 属性?还是我必须创建一个 IAuthorizationFilter 实现? :(
例子:
[Authorize]
public class Tools : Controller
{
public ActionResult Index()
{
return View();
}
}
当没有登录的用户访问http://example.com/tools时,我希望他们被重定向到http://example.com/account/logon?redirect=%2ftools,而不是默认的http://example.com/Account/LogOn?ReturnUrl=%2ftools
对于 /account/logon 部分,我可以在 Global.asax 中修改我的路由并进行更改
<authentication mode="Forms">
<forms loginUrl="~/account/logon" timeout="2880" />
</authentication>
在 web.config 中。但是我不知道如何更改 ReturnUrl 参数。
【问题讨论】:
-
我知道我在这个讨论中很晚了,但我有同样的问题,所以我向微软发布了一个增强请求。 visualstudio.uservoice.com/forums/121579-visual-studio/… 随意为它投票、评论等等。如果票数足够,它可能会引起他们的注意。
标签: c# asp.net-mvc-3