简体   繁体   English

将IIS应用程序池设置还原为应用程序默认设置

[英]Restore IIS Application Pool settings to Application defaults

latest versions of IIS allows to set Application Pool Defaults that applies to all not-changed settings of application pools and that writes tag in applicationHost.config. IIS的最新版本允许设置应用程序池默认值,该默认值适用于所有未更改的应用程序池设置,并在applicationHost.config中写入标记。 I can't find info about how to reset an app pool to defaults or force Defaults to be re-applied to app pools overwriting custom settings. 我找不到有关如何将应用程序池重置为默认值或强制将默认值重新应用于覆盖自定义设置的应用程序池的信息。 For other types of settings there's a "Revert to Parent" action that restore settings to defaults, there's something similar also for Application Pool Defaults? 对于其他类型的设置,有一个“还原为父项”操作可将设置恢复为默认值,“应用程序池默认值”也有类似的东西吗? Thanks in advance. 提前致谢。

unfortunately AFAIK there is no easy programmatic way to achieve that, the applicationPools section is one of those special ones that has a defaults (applicationPoolDefaults) and since it is a collection you certainly do not want to reset it to parent since that would erase all application pools. 不幸的是AFAIK没有简单的编程方式来实现这一点,applicationPools部分是具有默认值(applicationPoolDefaults)的特殊部分之一,由于它是一个集合,所以您当然不希望将其重置为父级,因为这会擦除所有应用程序池。 The idea is you want to remove all attributes and elements that have been set and that is very easy to do looking in c:\\windows\\system32\\inetsrv\\config\\applicationHost.config, so you can look there for and you'll see easily which ones are overriding values. 这个想法是您要删除所有已设置的属性和元素,并且在c:\\ windows \\ system32 \\ inetsrv \\ config \\ applicationHost.config中查找非常容易,因此您可以在其中查找并看到轻松地覆盖最重要的值。 You will also quickly see that it is not the right thing to just reset values there since you would end up changing the version of .NET or the identity or some things that might actually be correctly set on a per application basis. 您还将很快看到,仅在此处重置值是不正确的,因为最终您将更改.NET的版本或标识,或者可能实际上是根据每个应用程序正确设置的某些内容。 for example in my case you can see that the BizTalk Adapter is changing some values such as identityType and others. 例如,在我的情况下,您可以看到BizTalk适配器正在更改某些值,例如identityType和其他。 you could just remove all values (except name) and that truly would reset the values to the applicationPoolDefaults: 您可以删除所有值(名称除外),这确实会将值重置为applicationPoolDefaults:

    <applicationPools>
        <add name="DefaultAppPool" managedRuntimeVersion="v4.0" />
        <add name=".NET v4.5 Classic" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" />
        <add name=".NET v4.5" managedRuntimeVersion="v4.0" />
        <add name="Classic .NET AppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" />
        <add name=".NET v2.0 Classic" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" />
        <add name=".NET v2.0" managedRuntimeVersion="v2.0" />
        <add name="BizTalk Adapter AppPool" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" startMode="AlwaysRunning">
            <processModel identityType="NetworkService" />
        </add>

If you are comfortable with C# I would recommend instead using something like Microsoft.Web.Administration to see what is actually set and reset the ones you feel comfortable, something like the following snippet would do the trick, and the nice thing is you could use the Remote capabilities of MWA to monitor servers remotely if you wanted to instead of opening the files in notepad: 如果您对C#感到满意,我建议您改用Microsoft.Web.Administration之类的东西来查看实际设置并重置您感到满意的东西,类似以下代码片段的方法可以解决问题,而且很高兴您可以使用MWA的远程功能(如果需要)来远程监视服务器,而不是在记事本中打开文件:

    static void Main(string[] args)
    {
        ServerManager mgr = new ServerManager();

        foreach (var pool in mgr.ApplicationPools)
        {
            Console.WriteLine(pool.Name);
            IterateElement(pool, "\t");
            Console.WriteLine();
        }
    }

    private static void IterateElement(ConfigurationElement configElement, string indent)
    {
        foreach (var attribute in configElement.Attributes)
        {
            if (!attribute.IsInheritedFromDefaultValue && (bool)attribute.GetMetadata("isPresent"))
            {
                Console.WriteLine("{0}'{1}'='{2}'", indent, attribute.Name, attribute.Value);
            }
        }

        foreach (var child in configElement.ChildElements)
        {
            if (child.IsLocallyStored)
            {
                Console.WriteLine("{0}<{1}>", indent, child.Schema.Name);
                IterateElement(child, indent + "\t");
            }
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM