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

查看:40
本文介绍了当我从 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.

To use this template with Windows Azure authentication, refer to 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. 在功能视图中,双击身份验证.
  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 Server > Security 并确保选中 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天全站免登陆