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

2
  • 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?
    – Steve P
    Mar 22, 2013 at 18:59
  • That's exactly right
    – scripni
    Mar 25, 2013 at 9:21

2 Answers 2

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.

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.

1
  • 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, 2013 at 11:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .