0

在带有 IIS 8.5 的 windows server 2012r2 机器上,我有一个纯 html 站点,其中包含 web.config。

我的配置:

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
      <authentication mode="Windows"/>
    </system.web>

</configuration>

不幸的是,IIS 似乎没有选择我的身份验证模式设置。我可以通过将身份验证类型设置为 windows 来在 IIS 中进行这项工作,但这将涉及我更新每台服务器。IIS 是否有某种方法可以从 web.config 中提取配置,以便在部署时正确设置该值?这似乎是处理 IIS 和 web.config 的几乎所有其他事情的情况,所以我敢说我没有做正确的事情。

4

2 回答 2

0

您的网站是子应用程序吗?

尝试添加

<authorization>
 <deny users="?" />
</authorization>

或者

<identity impersonate="true" />
于 2014-11-05T18:51:09.437 回答
0

所以显然 IIS 并没有真正监听 web.config,除非您解锁应用程序主机配置中的相应部分。

qBernard http://forums.iis.net/members/qbernard.aspx在这里发布了答案:http: //forums.iis.net/t/1146296.aspx ?How+to+set+authentication+with+appcmd+exe +或+服务器管理器

(这是他所说的链接可能中断时的内容)对于 appcmd,您可以通过 /section:xxxx 进行设置。除 Form 外,所有身份验证方案都被锁定,因此您要么先解锁它,要么在 apphost 级别提交它(意味着将配置存储在 applicationHost.config 中,这不如通过 web.config 文件进行 xcopy 部署。

例子。appcmd 设置配置“默认网站”/section:windowsAuthentication /enabled:true /commit:apphost

或先解锁: appcmd unlock config /section:windowsAuthentication appcmd set config "default web site" /section:windowsAuthentication /enabled:true

于 2015-05-13T19:08:52.557 回答