MVC网站仅启用Windows身份验证,转发到/帐户/登录

Chr*_*ney 13 asp.net-mvc windows-authentication

我有一个MVC3网站设置只启用了Windows身份验证(因此匿名和表单被禁用).每当我尝试点击默认页面时,某些内容会将我转发到此URL;

.../MyApp的/帐号/登录?RETURNURL =%2fMyApp%2F

我得到一个错误;

无法找到该资源.说明:HTTP 404.您要查找的资源(或其中一个依赖项)可能已被删除,名称已更改或暂时不可用.请查看以下网址,确保拼写正确.

请求的URL:/ MyApp/Account/Login

我的web.config中没有任何内容配置为查找此URL,但是有一个关于使用表单身份验证的部分我已删除;

<authentication mode="Forms">
    <forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
Run Code Online (Sandbox Code Playgroud)

我应该重新配置此设置而不是彻底删除它吗?我尝试添加这个;

<authentication mode="Windows"></authentication>
Run Code Online (Sandbox Code Playgroud)

但它仍然转发回到同一个地方.我还有什么额外的事吗?

Chr*_*ney 19

好的,所以我看到了以下文章:http://martinnormark.com/asp-net-mvc-3-windows-authentication-problem-redirects-to-account-login

从那以后,我在应用程序设置部分的web.config中添加了以下键:

<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false"/>
Run Code Online (Sandbox Code Playgroud)

这解决了我的问题 - Windows身份验证现在按预期工作,并且没有更多重定向到不存在的登录页面.