我们有一种情况,我们需要明确限制一个网站的system.web/processModel/maxAppDomains = 1 。 问题是system.web/processModel默认情况下只能在machine.config级别设置:
<configuration> <configSections> <sectionGroup name="system.web"> <section name="processModel" allowDefinition="MachineOnly" /> </sectionGroup> </configSections> <configuration>
我知道%windir%/system32/inetsvr/appcmd.exe可以用来更新IISconfiguration设置,但是我还没有find更新processModel节定义的allowDefinition属性的方法。 任何人都可以在这里指出正确的方向吗?
谢谢
使用WMI提供程序:
' SetAllowDefinition is a static method, you should call it by getting a class object, as in the following example Set oAnonAuth = oWebAdmin.Get("AnonymousAuthenticationSection") oAnonAuth.SetAllowDefinition "MachineOnly"
基于我的理解,我认为你是在AllowDefinition设置为[AppHostOnly]或[MachineToApplication]值。
ref: http : //msdn.microsoft.com/en-us/library/bb386461( v= vs.90).aspx
注意:对ProcessModelSection类的更改仅在重新启动辅助进程时生效,而不是在更改设置后立即生效。
我用下面的代码将maxAppDomain = 1设置为当前的Web应用程序“但您可以通过提供path来更改它的任何.config文件”
System.Configuration.Configuration configuration = WebConfigurationManager.OpenWebConfiguration(""); System.Web.Configuration.ProcessModelSection processModelSection = (ProcessModelSection)configuration.GetSection("system.web/processModel"); processModelSection.MaxAppDomains = 1;
希望这是帮助,但我不得不承担一些事情,因为问题的要求需要进一步澄清。
你有没有尝试直接编辑machine.config文件? 每次遇到machine.config文件问题时,我都直接编辑文件。