用于在IIS 7中重建applicationHost.config的命令

Mac*_*ver 16 iis-7 windows-server-2008 applicationhost http-status-code-401

有没有办法使用Windows命令在IIS 7中重建applicationHost.config文件?或者,如果您可以通过修改此文件来帮助我解决问题,那也没关系.将此文件与其他服务器进行比较时,我注意到在删除站点和几个应用程序池后缺少或不同的非常重要的部分.

我绝不是IIS 7的专家,但我已经使用它7年了.我有信心为新网站配置执行了所有正确的步骤,它仍然给我这个错误,"401.1 "You are not authorized to view this page. You do not have permission to view this directory or page using the credentials that you supplied."

C:\Windows\System32\inetsrv\config\applicationHost.config
Run Code Online (Sandbox Code Playgroud)

这发生在IIS APPPOOL {app pool user}不存在的机器上,所以我们从未使用过此用户,就像我通常在配置权限时那样.然而,我们上周在IIS_IUSRS(在此组中使用IUSR)中添加了适当的权限,并且该网站运行正常.我们正在使用Windows身份验证,并且所有其他身份验证方法都已关闭.没有虚拟目录.我们使用的是.NET 4.0,Classic和32位应用程序(在高级设置下).

我们必须通过在绑定的"C:\ Windows\System32\inetsrv"中执行以下命令来手动更新主机名,因为当VeriSign SSL证书添加到绑定时,IIS会使主机名变灰.

appcmd set site /site.name:"himc" /+bindings.[protocol='https',bindingInformation='*:443:subdomain.domain.com']
Run Code Online (Sandbox Code Playgroud)

缺少"坏"Web服务器上的部分:

1 - 存在于"好"框中,在"坏"框中丢失

<customMetadata>
    <key path="LM/W3SVC/INFO">
        <property id="4012" dataType="String" userType="1" attributes="Inherit" value="NCSA Common Log File Format,Microsoft IIS Log File Format,W3C Extended Log File Format,ODBC Logging" />
        <property id="2120" dataType="MultiSZ" userType="1" attributes="None" value="400,0,,,0&#xA;" />
    </key>
</customMetadata>
Run Code Online (Sandbox Code Playgroud)

2 - 存在于"好"框中,在"坏"框中丢失

    <asp>
        <cache diskTemplateCacheDirectory="%SystemDrive%\inetpub\temp\ASP Compiled Templates" />
    </asp>
Run Code Online (Sandbox Code Playgroud)

3 - 此部分存在于"好"框中,但"坏"框中仅存在2.0(前2行).

<isapiFilters>
    <filter name="ASP.Net_2.0.50727.0" path="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_filter.dll" enableCache="true" preCondition="bitness32,runtimeVersionv2.0" />
    <filter name="ASP.Net_2.0.50727-64" path="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_filter.dll" enableCache="true" preCondition="bitness64,runtimeVersionv2.0" />
    <filter name="ASP.Net_2.0_for_V1.1" path="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_filter.dll" enableCache="true" preCondition="runtimeVersionv1.1" />
    <filter name="ASP.Net_4.0_64bit" path="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_filter.dll" enableCache="true" preCondition="runtimeVersionv4.0,bitness64" />
    <filter name="ASP.Net_4.0_32bit" path="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll" enableCache="true" preCondition="runtimeVersionv4.0,bitness32" />
</isapiFilters>
Run Code Online (Sandbox Code Playgroud)

4 - 此部分存在于"坏"框中,但在"好"框中缺失

    <applicationDependencies>
        <application name="Active Server Pages" groupId="ASP" />
    </applicationDependencies>
Run Code Online (Sandbox Code Playgroud)

5 - "好"框中缺少ssiExecDisable属性

    <serverSideInclude ssiExecDisable="false" />
Run Code Online (Sandbox Code Playgroud)

6 - "坏"框中缺少部分

        <authentication>
            <anonymousAuthentication enabled="false" />
            <windowsAuthentication enabled="true" />
        </authentication>
Run Code Online (Sandbox Code Playgroud)

Mac*_*ver 58

显然,Microsoft会将这些文件的历史记录保存在:

C:\inetpub\history\
Run Code Online (Sandbox Code Playgroud)

  • 加1是MacGyver (10认同)

小智 5

首先备份所有配置文件!

显然,IIS 在 C:\inetpub\history 中保留了配置文件的历史记录。因此,您需要做的是记住 IIS 正常运行的最后一个已知日期,然后从 c:\inetpub\history 复制配置文件的内容并替换 c:\windows\system32\inetsrv\config 中的配置文件。

祝你好运!