3

We have a situation where we need to explicitly limit the system.web/processModel/maxAppDomains = 1 for one website. The problem is that system.web/processModel can only be set at the machine.config level by default:

<configuration>
    <configSections>
        <sectionGroup name="system.web">
            <section name="processModel" allowDefinition="MachineOnly" />
        </sectionGroup>
   </configSections>
<configuration>

I know that %windir%/system32/inetsvr/appcmd.exe can be used to update IIS config settings, but I haven't found a way to update the allowDefinition attribute of the processModel section definition. Can anyone point me in the right direction here?

Thanks

scripni
  • 33
  • 5
  • just to be clear... you know how to set the process model section for a specific site, but you're trying to find a scripted way to modify allowDefinition="blahblah" so that your per-site settings will work? – explunit Mar 22 '13 at 18:59
  • That's exactly right – scripni Mar 25 '13 at 09:21

2 Answers2

1

using WMI provider:

' 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"

based on my understanding, i think you are intersted in setting AllowDefinition to [AppHostOnly] or [MachineToApplication] values.

ref:http://msdn.microsoft.com/en-us/library/bb386461(v=vs.90).aspx

note: Changes to the ProcessModelSection class take effect only when the worker process is restarted, not immediately after the setting is changed.

i used the following code to set maxAppDomain=1 to the current web app "but you can change it for any .config file by providing the path"

System.Configuration.Configuration configuration = WebConfigurationManager.OpenWebConfiguration("");
            System.Web.Configuration.ProcessModelSection processModelSection =
                        (ProcessModelSection)configuration.GetSection("system.web/processModel");
            processModelSection.MaxAppDomains = 1;

hope that's help, yet i had to assume couple of things since the question requirements need further clarifications.

Jawad Al Shaikh
  • 254
  • 1
  • 3
  • 15
0

Have you tried editing the machine.config file directly? Every time I've run into issues with the machine.config file I've just edited the file directly.

Techie Joe
  • 327
  • 2
  • 9
  • The problem is that we need to do this as part of a deployment, so automating it in some way is our preferred option. – scripni Apr 30 '13 at 11:09