IIS 快速 Windows 身份验证
我正在尝试将 IIS Express 与 VS2010 一起使用来托管 silverlight 应用程序。我修改了 applicationhost.config 文件以允许修改正确的配置设置。我的 web.config 中有以下内容:
<location path="">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
我没有经过身份验证,并且我的域服务调用以用户身份返回空记录。在安装 VS2010 SP1 BETA 后我能够让它工作,但我试图让它仅与 IIS Express 一起工作。
如何启用 Windows 身份验证以与 IIS Express 一起使用。是否有我缺少的配置设置?
I'm trying to use IIS Express with VS2010 to host a silverlight application. I modified my applicationhost.config file to allow for modification of the proper configuration settings. I have the following in my web.config:
<location path="">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
I am not being authenticated and my domain service call returns a null record as the user. I was able to get this to work after installing VS2010 SP1 BETA but I'm trying to get this to work with only IIS Express.
How do I enable Windows Authentication to work with IIS Express. Is there a configuration setting that I am missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
Visual Studio 2010 SP1 和 2012 添加了对 IIS Express 的支持,无需编辑尖括号。
我相信这个解决方案优于 vikomall 的选项。
上面基于 UI 的解决方案使用 IIS Express 的 applicationHost.config 中特定于站点的位置元素,使应用程序保持不变。
更多信息请点击这里:
http://msdn.microsoft.com/en-us/magazine/hh288080.aspx
Visual Studio 2010 SP1 and 2012 added support for IIS Express eliminating the need to edit angle brackets.
I believe this solution is superior to the vikomall's options.
The UI-based solution above uses site-specific location elements in IIS Express's applicationHost.config leaving the app untouched.
More information here:
http://msdn.microsoft.com/en-us/magazine/hh288080.aspx
option-1:
编辑
\My Documents\IISExpress\config\applicationhost.config
文件并启用windowsAuthentication,即:option-2:
解锁windowsAuthentication \My Documents\IISExpress\config\applicationhost.config 中的部分如下将
所需身份验证类型的覆盖设置更改为“允许”
在应用程序的 web.config 中添加以下内容
以下链接可能会有所帮助:
http://learn.iis.net/page。 aspx/376/delegating-configuration-to-webconfig-files/
安装 VS 2010 SP1 后,可能需要应用选项 1 + 2 才能使 Windows 身份验证正常工作。此外,您可能需要在 IIS Express applicationhost.config 中将匿名身份验证设置为 false:
对于 VS2015,IIS Express applicationhost 配置文件可能位于此处:
和<项目文件中的 /code> 选项选择默认或特定于解决方案的配置文件。
option-1:
edit
\My Documents\IISExpress\config\applicationhost.config
file and enable windowsAuthentication, i.e:option-2:
Unlock windowsAuthentication section in \My Documents\IISExpress\config\applicationhost.config as follows
Alter override settings for the required authentication types to 'Allow'
Add following in the application's web.config
Below link may help:
http://learn.iis.net/page.aspx/376/delegating-configuration-to-webconfig-files/
After installing VS 2010 SP1 applying option 1 + 2 may be required to get windows authentication working. In addition, you may need to set anonymous authentication to false in IIS Express applicationhost.config:
for VS2015, the IIS Express applicationhost config file may be located here:
and the
<UseGlobalApplicationHostFile>
option in the project file selects the default or solution-specific config file.根据 booij boy 的回答,检查您是否检查了“Windows 身份验证”功能
控制面板->节目->打开或关闭 Windows 功能 ->互联网信息服务->万维网服务 ->安全性
此外,使用 Firefox 或 Internet Explorer 时似乎存在很大差异。
启用“Windows 身份验证”后,它对我有效,但仅在 IE 中有效。
Building upon the answer from booij boy, check if you checked the "windows authentication" feature in
Control Panel -> Programs -> Turn windows features on or of -> Internet Information Services -> World Wide Web Services -> Security
Also, there seems to be a big difference when using firefox or internet explorer.
After enabeling the "windows authentication" it works for me but only in IE.
除了这些很好的答案之外,在 IISExpress 开发环境的上下文中,为了阻止臭名昭著的“system.web/identity@impersonate”错误,您可以简单地确保以下设置在您的 applicationhost.config 文件中就位。
这将使您在开发和测试过程中具有更大的灵活性,但在这样做之前请确保您了解在生产环境中使用此设置的含义。
有用的帖子:
In addition to these great answers, in the context of an IISExpress dev environment, and in order to thwart the infamous "system.web/identity@impersonate" error, you can simply ensure the following setting is in place in your applicationhost.config file.
This will allow you more flexibility during development and testing, though be sure you understand the implications of using this setting in a production environment before doing so.
Helpful Posts:
在 IIS 管理器中单击您的站点。
您需要在“功能视图”(而不是“内容视图”)
中的“功能视图”的 IIS 部分中选择所谓的功能“身份验证”
并双击它。
您可以在此处启用 Windows 身份验证。
这也是可能的(我认为在线程中的建议之一)通过 web.config 中的设置(...)
但也许你有一个 web.config,你不想花太多时间。
那么这个线程不会有太多帮助,这就是我添加这个答案的原因。
In IIS Manager click on your site.
You need to be "in feature view" (rather than "content view")
In the IIS section of "feature view" choose the so-called feature "authentication"
and doulbe click it.
Here you can enable Windows Authentication.
This is also possible (by i think in one of the suggestions in the thread) by a setting in the web.config ( ...)
But maybe you have a web.config you do not want to scrue too much around with.
Then this thread wouldnt be too much help, which is why i added this answer.
如果出现以下情况,此答案可能会有所帮助:1) 您的网站在升级到 Visual Studio 2015 之前曾经使用 Windows 身份验证,2) 并且您的网站正在尝试加载
/login.aspx
(即使没有此类验证)您网站上的文件)。将以下两行添加到网站
Web.config
的appSettings
部分。This answer may help if: 1) your site used to work with Windows authentication before upgrading to Visual Studio 2015 and 2) and your site is attempting to load
/login.aspx
(even though there is no such file on your site).Add the following two lines to the
appSettings
section of your site'sWeb.config
.同样的注释 - VS 2015,.vs\config\applicationhost.config 不可见或不可用。
默认情况下 .vs 文件夹是隐藏的(至少在我的情况下)。
如果找不到 .vs 文件夹,请按照以下步骤操作。
属性
部分,单击隐藏
复选框(默认未选中),重复步骤 1 到 5,除了
步骤 3
,这次您需要取消选中
之前选中的“隐藏”选项。现在应该可以看到 .vs 文件夹。
On the same note - VS 2015, .vs\config\applicationhost.config not visible or not available.
By default .vs folder is hidden (at least in my case).
If you are not able to find the .vs folder, follow the below steps.
Attributes
section, clickHidden
check box(default unchecked),Repeat step 1 to 5, except on
step 3
, this time you need touncheck
the 'Hidden' option that you checked previously.Now should be able to see .vs folder.
在完成上述答案中的所有操作后,我发现我没有以管理员身份运行 Visual Studio。以管理员身份运行后,问题解决。
After doing everything in the above answers, I figured out I was not running Visual Studio as Admin. After running as Admin, problem solved.
如果所有答案都没有帮助,您可能需要调整项目属性。查看其他 StackOverflow 答案,了解如何执行此操作:
https://stackoverflow.com/a/20857049/56621
If none of the answers helps, you might need to adjust the project properties. Check this other StackOverflow answer on how to do that:
https://stackoverflow.com/a/20857049/56621
我正在使用 Visual Studio 2019 针对 ASP.Net 应用程序进行开发。以下是我们所做的工作:
系统.web我没有更改iis express中的application.config。
I'm using visual studio 2019 develop against ASP.Net application. Here's what been worked for us:
And I didn't change application.config in iis express.