当我从Visual Studio运行项目时,Windows身份验证不起作用 [英] Windows authentication doesn't work when I run project from Visual Studio

查看:159
本文介绍了当我从Visual Studio运行项目时,Windows身份验证不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在IIS上托管ASP.NET MVC项目时,Windows身份验证效果很好。但是,如果我从Visual Studio中运行它,则不会。

Windows authentication works good when I host my ASP.NET MVC project on IIS. But if I run it from Visual Studio - it doesn't.

这是我的Web.config:

Here is my Web.config:

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

我错过了什么吗?

推荐答案

如果要在IIS Express中托管(您可能应该这样做),请确保已在Web应用程序的属性中启用了Windows身份验证。

If you are hosting in IIS Express (which you probably should), make sure you have enabled Windows Authentication in the properties of your Web Application.

如果使用Intranet应用程序模板在Visual Studio中创建新的ASP.NET MVC 4应用程序,则会在屏幕上看到以下自述文件。因此,继续尝试,阅读并遵循那里写的内容:

By the way if you create a new ASP.NET MVC 4 application in Visual Studio using the Intranet Application template you will be greeted with the following Readme on the screen. So go ahead, try it, read it and follow what's written there:


要将此模板与Windows Azure身份验证一起使用,请参考
http://go.microsoft.com/fwlink/?LinkID=267940

否则,要将此模板用于Windows身份验证,请参考
以下说明:

Otherwise, to use this template with Windows authentication, refer to the instructions below:

在IIS Express上托管:

Hosting on IIS Express:


  1. 在解决方案资源管理器中单击您的项目以选择该项目。

  2. 如果属性窗格未打开,将其打开(F4)。

  3. 在项目的属性窗格中:

    a)将匿名身份验证设置为已禁用。

    b)将 Windows身份验证设置为
    启用。

在IIS 7或更高版本上托管:

Hosting on IIS 7 or later:


  1. 打开IIS管理器并导航到您的网站。

  2. 在功能视图中,双击Authenti

  3. 在身份验证页面上,选择Windows身份验证。如果没有Windows身份验证,则需要确保
    Windows身份验证已安装在服务器上。

要在Windows上启用Windows身份验证,请执行以下操作:

To enable Windows authentication on Windows:

a)在控制面板中,打开程序和功能。
b)选择打开或关闭Windows功能。
c)导航到Internet信息服务>万维网服务>安全性,并确保已选中Windows身份验证节点。

a) In Control Panel open "Programs and Features". b) Select "Turn Windows features on or off". c) Navigate to Internet Information Services > World Wide Web Services > Security and make sure the Windows authentication node is checked.

要在Windows Server上启用Windows身份验证,请执行以下操作:

To enable Windows authentication on Windows Server:

a)在服务器管理器中,选择 Web服务器(IIS),然后单击添加角色服务。
b)导航到 Web服务器>安全性,并确保已选中Windows身份验证节点。

a) In Server Manager, select Web Server (IIS) and click Add Role Services. b) Navigate to Web Server > Security and make sure the Windows authentication node is checked.


  1. 在操作窗格中,单击启用。要使用Windows身份验证。

  2. 在身份验证页上,选择匿名身份验证。

  3. 在操作窗格中,单击禁用以禁用匿名身份验证。


这篇关于当我从Visual Studio运行项目时,Windows身份验证不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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