ASP.NET MVC 5(Visual Studio 2013 预览版)更改 [授权] 的登录 URL [英] ASP.NET MVC 5 (Visual Studio 2013 Preview) Change Login Url for [Authorize]
问题描述
我开始尝试使用 ASP.NET MVC 5 预览版,到目前为止一切都很好(我只能推荐它).
I started playing around with the ASP.NET MVC 5 preview and everything has been going fine so far (I can only recommend it).
但是,我想知道在哪里可以设置内置 [Authorize]
-Attribute 的 Login-Url.我已将 AccountController
移动到一个区域,因此登录操作的路径不再是 /Account/Login
而是 MyArea/Account/Login
,它被 [Authorize]
-Attribute 忽略,这反过来意味着,无论何时导航到具有属性集的控制器或动作,都会被重定向到错误的路径 /账户/登录
.
However, I wonder where I can set the Login-Url for the Built-In [Authorize]
-Attribute. I've moved the AccountController
to a an area, so the path to the Login action is no longer /Account/Login
but MyArea/Account/Login
, which is ignored by the [Authorize]
-Attribute, which in turn means, that whenever one navigates to a controller or action with the attribute set, one is redirected to the wrong path /Account/Login
.
推荐答案
在 web.config
中查找类似这样的部分:
Look in web.config
for a section like this:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
更改 loginUrl
值以指向您更新后的登录页面.
Change the loginUrl
value to point to your updated login page.
这篇关于ASP.NET MVC 5(Visual Studio 2013 预览版)更改 [授权] 的登录 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!