IIS 快速 Windows 身份验证

发布于 2024-10-13 11:03:13 字数 615 浏览 11 评论 0原文

我正在尝试将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

小伙你站住 2024-10-20 11:03:13

Visual Studio 2010 SP1 和 2012 添加了对 IIS Express 的支持,无需编辑尖括号。

  1. 如果您还没有这样做,请右键单击 Web 风格的项目并选择“使用 IIS Express...”。
  2. 完成后,选择 Web 项目并按 F4 聚焦“属性”面板。
  3. 将“Windows 身份验证”属性设置为“启用”,将“匿名身份验证”属性设置为“禁用”。

在此处输入图像描述

我相信这个解决方案优于 vikomall 的选项。

  • 选项 #1 是对所有 IIS Express 站点的全局更改。
  • 选项 #2 在 web.config 中留下了开发痕迹。
    • 此外,部署到 IIS 7.5 时可能会导致错误,除非您按照 IIS 服务器的 applicationHost.config 上的“解锁”过程进行操作。

上面基于 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.

  1. If you haven't already, right-click a web-flavored project and select "Use IIS Express...".
  2. Once complete, select the web project and press F4 to focus the Properties panel.
  3. Set the "Windows Authentication" property to Enabled, and the "Anonymous Authentication" property to Disabled.

enter image description here

I believe this solution is superior to the vikomall's options.

  • Option #1 is a global change for all IIS Express sites.
  • Option #2 leaves development cruft in the web.config.
    • Further, it will probably lead to an error when deployed to IIS 7.5 unless you follow the "unlock" procedure on your IIS server's applicationHost.config.

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

生生不灭 2024-10-20 11:03:13

option-1

编辑\My Documents\IISExpress\config\applicationhost.config文件并启用windowsAuthentication,即:

<system.webServer>
...
  <security>
...
    <authentication>
      <windowsAuthentication enabled="true" />
    </authentication>
...
  </security>
...
</system.webServer>

option-2

解锁windowsAuthentication \My Documents\IISExpress\config\applicationhost.config 中的部分如下将

<add name="WindowsAuthenticationModule" lockItem="false" />

所需身份验证类型的覆盖设置更改为“允许”

<sectionGroup name="security">
    ...
    <sectionGroup name="system.webServer">
        ...
        <sectionGroup name="authentication">
            <section name="anonymousAuthentication" overrideModeDefault="Allow" />
            ...
            <section name="windowsAuthentication" overrideModeDefault="Allow" />
    </sectionGroup>
</sectionGroup>

在应用程序的 web.config 中添加以下内容

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
      <security>
        <authentication>
          <windowsAuthentication enabled="true" />
        </authentication>
      </security>
    </system.webServer>
</configuration>

以下链接可能会有所帮助:
http://learn.iis.net/page。 aspx/376/delegating-configuration-to-webconfig-files/

安装 VS 2010 SP1 后,可能需要应用选项 1 + 2 才能使 Windows 身份验证正常工作。此外,您可能需要在 IIS Express applicationhost.config 中将匿名身份验证设置为 false:

<authentication>

            <anonymousAuthentication enabled="false" userName="" />

对于 VS2015,IIS Express applicationhost 配置文件可能位于此处:

$(solutionDir)\.vs\config\applicationhost.config

<项目文件中的 /code> 选项选择默认或特定于解决方案的配置文件。

option-1:

edit \My Documents\IISExpress\config\applicationhost.config file and enable windowsAuthentication, i.e:

<system.webServer>
...
  <security>
...
    <authentication>
      <windowsAuthentication enabled="true" />
    </authentication>
...
  </security>
...
</system.webServer>

option-2:

Unlock windowsAuthentication section in \My Documents\IISExpress\config\applicationhost.config as follows

<add name="WindowsAuthenticationModule" lockItem="false" />

Alter override settings for the required authentication types to 'Allow'

<sectionGroup name="security">
    ...
    <sectionGroup name="system.webServer">
        ...
        <sectionGroup name="authentication">
            <section name="anonymousAuthentication" overrideModeDefault="Allow" />
            ...
            <section name="windowsAuthentication" overrideModeDefault="Allow" />
    </sectionGroup>
</sectionGroup>

Add following in the application's web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
      <security>
        <authentication>
          <windowsAuthentication enabled="true" />
        </authentication>
      </security>
    </system.webServer>
</configuration>

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:

<authentication>

            <anonymousAuthentication enabled="false" userName="" />

for VS2015, the IIS Express applicationhost config file may be located here:

$(solutionDir)\.vs\config\applicationhost.config

and the <UseGlobalApplicationHostFile> option in the project file selects the default or solution-specific config file.

浅笑依然 2024-10-20 11:03:13

根据 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.

提笔落墨 2024-10-20 11:03:13

除了这些很好的答案之外,在 IISExpress 开发环境的上下文中,为了阻止臭名昭著的“system.web/identity@impersonate”错误,您可以简单地确保以下设置在您的 applicationhost.config 文件中就位。

<configuration>
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
    </system.webServer>
</configuration>

这将使您在开发和测试过程中具有更大的灵活性,但在这样做之前请确保您了解在生产环境中使用此设置的含义。

有用的帖子:

  • http://forums.iis.net/post/1873372.aspx
  • < a href="http://www.iis.net/learn/application-frameworks/building-and-running-aspnet-applications/aspnet-20-writing-changes-on-iis" rel="noreferrer">http: //www.iis.net/learn/application-frameworks/building-and-running-aspnet-applications/aspnet-20-writing-changes-on-iis

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.

<configuration>
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
    </system.webServer>
</configuration>

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:

梦归所梦 2024-10-20 11:03:13

在 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.

木有鱼丸 2024-10-20 11:03:13

如果出现以下情况,此答案可能会有所帮助:1) 您的网站在升级到 Visual Studio 2015 之前曾经使用 Windows 身份验证,2) 并且您的网站正在尝试加载 /login.aspx(即使没有此类验证)您网站上的文件)。

将以下两行添加到网站 Web.configappSettings 部分。

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

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 appSettingssection of your site's Web.config.

<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false"/>
·深蓝 2024-10-20 11:03:13

同样的注释 - VS 2015,.vs\config\applicationhost.config 不可见或不可用。

默认情况下 .vs 文件夹是隐藏的(至少在我的情况下)。

如果找不到 .vs 文件夹,请按照以下步骤操作。

  1. 右键单击解决方案文件夹,
  2. 选择“属性”,
  3. 属性部分,单击隐藏复选框(默认未选中),
  4. 然后单击“应用”按钮,
  5. 将显示确认窗口选择“将更改应用于此文件夹、子文件夹和文件”选项,点击“确定”。

    重复步骤 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.

  1. Right click on the Solution folder
  2. select 'Properties'
  3. In Attributes section, click Hidden check box(default unchecked),
  4. then click the 'Apply' button
  5. It will show up confirmation window 'Apply changes to this folder, subfolder and files' option selected, hit 'Ok'.

    Repeat step 1 to 5, except on step 3, this time you need to uncheck the 'Hidden' option that you checked previously.

Now should be able to see .vs folder.

笙痞 2024-10-20 11:03:13

在完成上述答案中的所有操作后,我发现我没有以管理员身份运行 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.

滥情空心 2024-10-20 11:03:13

如果所有答案都没有帮助,您可能需要调整项目属性。查看其他 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

梓梦 2024-10-20 11:03:13

我正在使用 Visual Studio 2019 针对 ASP.Net 应用程序进行开发。以下是我们所做的工作:

  1. 打开您的项目属性窗口,禁用匿名身份验证并启用Windows身份验证
  2. 在您的Web.Config系统.web
<authentication mode="Windows"></authentication>

我没有更改iis express中的application.config。

I'm using visual studio 2019 develop against ASP.Net application. Here's what been worked for us:

  1. Open your Project Property Windows, Disable Anonymous Authentication and Enable Windows Authentication
  2. In your Web.Config under system.web

<authentication mode="Windows"></authentication>

And I didn't change application.config in iis express.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文