问题ASP.NET MVC 3 Beta版完全使用Windows身份验证 [英] Problem exclusively using Windows Authentication in ASP.NET MVC 3 Beta

查看:140
本文介绍了问题ASP.NET MVC 3 Beta版完全使用Windows身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建ASP.NET MVC 3测试版的内部网站,并希望只使用Windows身份验证。此外,我想使用Visual Studio开发服务器VS2010中。

I'm creating an Intranet site in ASP.NET MVC 3 Beta and would like to use Windows Authentication exclusively. In addition, I'd like to use the Visual Studio Development Server in VS2010.

我修改了默认的web.config文件删除到窗体身份验证的所有引用,并切换到这一点:

I modified the default web.config file to remove all references to forms authentication and switched to this:

<authentication mode="Windows"  />
<authorization>
  <deny users="?" />
</authorization>

然而,当我启动我的网站,并获得默认页,我得到这个答复:

However, when I launch my site and get the default page, I get this reply:

HTTP/1.1 302 Found
Server: ASP.NET Development Server/10.0.0.0
Date: Tue, 02 Nov 2010 14:05:19 GMT
X-AspNet-Version: 4.0.30319
Location: /Account/Login?ReturnUrl=%2f
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 145
Connection: Close

这导致了这个消息,我的浏览器:

Which leads to this message in my browser:

中的服务器错误'/'应用。

Server Error in '/' Application.

资源无法找到。

说明:HTTP 404资源
  你正在寻找(或它的一个
  依赖关系)可能已被移除,
  更名,或
  暂时不可用。请
  检查以下URL并确保
  它拼写正确。

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

请求的URL:/帐号/登录

Requested URL: /Account/Login

版本信息:微软.NET
  Framework版本:4.0.30319; ASP.NET
  版本:4.0.30319.1版本:4.0.30319.1

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 Version:4.0.30319.1

如果我在使用Visual Studio开发服务器下的项目属性选择NTLM验证,然后我得到正确的连接上这个答复:

If I select the "NTLM Authentication" in the project properties under "Use Visual Studio Development Server" then I correctly get this reply on connect:

HTTP/1.1 401 Unauthorized Server
ASP.NET Development Server/10.0.0.0
Date: Tue, 02 Nov 2010 14:07:37 GMT
Content-Length: 1211 
WWW-Authenticate: NTLM

但是当我认证,我得到302

But then when I authenticate, I get the 302

我认为这只是清除了一些默认值的问题,但我不知道(/帐号/登录没有任何地方在我的web.config文件中出现)。如果删除了拒绝部分,那么事情做工精细,只是我没有得到一个验证的主要和有效保持匿名。

I think this is just a matter of clearing out some default value but am not sure ("/Account/Login" doesn't appear anywhere in my web.config files). If I remove the "deny" part then things work fine except that I don't get an authenticated Principal and effectively remain anonymous.

我相信这使用只是改变了身份验证模式到Windows中的ASP.NET MVC 2和VS2008工作,但它似乎并没有工作方式了。

I believe this used to work in ASP.NET MVC 2 and VS2008 by just changing the authentication mode to Windows, however it doesn't seem to work that way any more.

我知道我可能失去了一些东西基本。谢谢!

I know I'm probably missing something basic. Thanks!

注意:这个问题是类似<一个href=\"http://stackoverflow.com/questions/548603/problem-restricting-anonymous-access-to-an-asp-net-mvc-site\">Problem限制到一个ASP.Net MVC网站的问题匿名访问,但不同之处在于我想只使用Windows身份验证。

Note: This question is similar to the "Problem restricting anonymous access to an ASP.Net MVC Site" question, but different in that I want to exclusively use Windows authentication.

推荐答案

我有完全相同的问题。原来有在MVC 3的变化(相当好隐藏的,太)有Forms身份验证默认情况下自动启用,以禁用它下面的行添加到您的根Web.config文件,在的appSettings 键...

I had exactly the same problem. Turns out there was a change in MVC 3 (fairly well hidden, too) that has Forms authentication automatically enabled by default, in order to disable it add the following line to your root Web.config file, under the appSettings key...

<add key="autoFormsAuthentication" value="false" />

希望帮助!

这篇关于问题ASP.NET MVC 3 Beta版完全使用Windows身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆