C# 帮助:如何在 ASP.NET 开发服务器上启用 Windows 身份验证?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/854395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 04:18:19  来源:igfitidea点击:

Help: How to enable Windows Authentication on ASP.NET Development Server?

c#asp.netvisual-studiowcfiis

提问by

I hope any of you guys knows how to fix this issue we are having.

我希望你们中的任何人都知道如何解决我们遇到的这个问题。

We are trying to host a WCF service via the web. We set the web.config to have the service require windows authentication. The problem we are having is the following:

我们正在尝试通过 Web 托管 WCF 服务。我们将 web.config 设置为服务需要 Windows 身份验证。我们遇到的问题如下:

When we host our service in a regular IIS, the service runs fine and there is no issues with the "Windows Authentication" mode. However, when we try to run it from our developer boxes we get the following error: "Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service."

当我们在常规 IIS 中托管我们的服务时,该服务运行良好并且“Windows 身份验证”模式没有问题。但是,当我们尝试从我们的开发人员框中运行它时,我们会收到以下错误:“此服务的安全设置需要 Windows 身份验证,但未为承载此服务的 IIS 应用程序启用它。”

Our developers boxes are not hosting the service through the regular IIS but rather through Visual Studio's APS.NET Development Server. We tried going into the web project properties and said to enable NTLM authentication but that still did not fix it. Does anyone know how to fix it? Does VS ASP.NET Development Server even support Windows Authentication? Is the only option for hosting the service with Windows Authentication is to use IIS and forget about ASP.NET Development Server?

我们的开发人员盒子不是通过常规 IIS 托管服务,而是通过 Visual Studio 的 APS.NET 开发服务器托管服务。我们尝试进入 web 项目属性并说启用 NTLM 身份验证,但仍然没有解决它。有谁知道如何修理它?VS ASP.NET 开发服务器甚至支持 Windows 身份验证吗?使用 Windows 身份验证托管服务的唯一选择是使用 IIS 而忘记 ASP.NET 开发服务器吗?

Thanks Chuck

谢谢查克

回答by Tion

ASP.Net Development Server is very limited. It only serves requests originating from the same machine that it is running on, and it will not serve files that are outside of its application scope. It is based on the Cassini server. Cassini does not support WCF web services. Documentation for ASP.Net Development Server says that it does support NTLM. If you are just browsing to a page from the local machine it should work fine unless the page is referencing an unavailable resource.

ASP.Net 开发服务器非常有限。它只服务于来自它正在运行的同一台机器的请求,它不会服务于它的应用程序范围之外的文件。它基于 Cassini 服务器。Cassini 不支持 WCF Web 服务。ASP.Net 开发服务器的文档说它确实支持 NTLM。如果您只是从本地机器浏览到一个页面,它应该可以正常工作,除非该页面引用了不可用的资源。

check out http://msdn.microsoft.com/en-us/library/58wxa9w5.aspxfor more info.

查看http://msdn.microsoft.com/en-us/library/58wxa9w5.aspx了解更多信息。

回答by Calanus

I would install and configure IIS on your local dev machine and use that in preference to using the inbuilt webserver. To use local IIS to debug select "User Local IIS web server" on the web tab of the project properties. Using IIS rather than the inbuilt webserver also means that you can configure your app in exactly the same way as it will be configured on the production server and this will reduce the no of potential surprises when you move to the production environment.

我会在您的本地开发机器上安装和配置 IIS,并优先使用它而不是使用内置的网络服务器。要使用本地 IIS 进行调试,请在项目属性的 Web 选项卡上选择“用户本地 IIS Web 服务器”。使用 IIS 而不是内置的 Web 服务器还意味着您可以以与在生产服务器上配置完全相同的方式配置您的应用程序,这将减少当您转移到生产环境时的潜在意外。

回答by Brett

In order to configure IIS Express security settings:

为了配置 IIS Express 安全设置:

  1. look for the IIS express symbol in the taskbar (system tray).
  2. Right click and select "All Applications".
  3. Click on the name of the site you want to change (although I believe the change is site wide)
  4. Click on the path in the config section below (it will open the applicationhost.config file)
  5. Search for the authentication section and make your changes
  1. 在任务栏(系统托盘)中查找 IIS express 符号。
  2. 右键单击并选择“所有应用程序”。
  3. 单击要更改的站点的名称(尽管我相信更改是站点范围的)
  4. 单击下面配置部分中的路径(它将打开 applicationhost.config 文件)
  5. 搜索身份验证部分并进行更改

Example changes can be found here:

可以在此处找到示例更改:

http://toadcode.blogspot.ca/2011/08/security-config-in-iis-express.html

http://toadcode.blogspot.ca/2011/08/security-config-in-iis-express.html

回答by Shiroy

The solution to my authorization issue was to go into the F4 project properties and set the following:

我的授权问题的解决方案是进入 F4 项目属性并设置以下内容:

Anonymous Authentication: Disabled

Windows Authentication: Enabled

Apparently these properties update the IIS applicationHost.config directly.

显然这些属性直接更新 IIS applicationHost.config。

http://provenstyle.com/blog/2015/10/02/Visual-Studio-2015-Windows-Authentication-And-IIS-Express/

http://provenstyle.com/blog/2015/10/02/Visual-Studio-2015-Windows-Authentication-And-IIS-Express/