【发布时间】:2012-07-03 20:01:54
【问题描述】:
所以我有一个带有以下 web.config 的 ASP.NET MVC3 应用程序
<?xml version="1.0"?>
<configuration>
....
<system.web>
....
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" defaultUrl="~"
slidingExpiration="true" timeout="10080" />
</authentication>
和一个控制器:
[Authorize(Roles="admin")]
public class MetaStyleController : TunaController
{
....
public ActionResult Index()
{
....
如果我没有登录,并且尝试点击 http//localhost/myAppPath/MetaStyle ,我会被重定向到上面定义的登录页面,对吗?
那么为什么我会被重定向到http://localhost/myAppPath/Account/Login?ReturnUrl=%2fmyAppPath%2fMetaStyle? (请注意,该网址具有 Login 而不是 LogOn)
Login 来自哪里?我在我的项目中没有看到它。
【问题讨论】:
-
您在该 URL 看到有效页面吗?
-
Spender,看看 John Galloway 的这篇文章是否有帮助:weblogs.asp.net/jgalloway/archive/2012/05/04/…
-
所以我们正在搜索登录幻象 :) 我的猜测是父/子目录中的重叠 web.config 文件...帐户/登录名应该在某处定义...
-
@Colombo(好名字,顺便说一句!)那个网址什么都没有。
-
我会在解决方案范围内搜索文本“登录”以找到罪魁祸首。 :-)
标签: c# asp.net-mvc-3 redirect authorization forms-authentication