Home
%3CLINGO-SUB%20id%3D%22lingo-sub-305415%22%20slang%3D%22en-US%22%3EoverrideModeDefault%20and%20allowDefinition%20attributes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-305415%22%20slang%3D%22en-US%22%3E%3CP%3EThere%20are%20two%20attributes%20that%20come%20handy%20if%20you%20want%20to%20enforce%20application%20settings%20in%20IIS%3A%26nbsp%3B%3CCODE%3EoverrideModeDefault%3C%2FCODE%3E%20and%26nbsp%3B%3CCODE%3EallowDefinition%3C%2FCODE%3E.%20If%20your%20users%20try%20to%20override%20settings%20when%20these%20attributes%20are%20used%2C%20they%20may%20see%20to%20see%20HTTP%20Error%20500.19.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1673363136%22%20id%3D%22toc-hId-1760119368%22%3EoverrideModeDefault%20attribute%3C%2FH2%3E%0A%3CP%3EExample%3A%20If%20you%20don%E2%80%99t%20want%20anybody%20to%20change%20the%20default%20document%20in%20your%20IIS%2C%20use%26nbsp%3B%3CCODE%3EoverrideModeDefault%3C%2FCODE%3E%20attribute%20in%20the%20%3CCODE%3EapplicationHost%3C%2FCODE%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CCODE%3Econfig%3C%2FCODE%3E%20as%20the%20example%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CCODE%3E%3CSPAN%3E%3CSECTIONGROUP%3E%3C%2FSECTIONGROUP%3E%3C%2FSPAN%3E%20%3CSPAN%3Ename%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22system.webServer%22%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%20%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSECTION%3E%3C%2FSECTION%3E%3C%2FSPAN%3E%20%3CSPAN%3Ename%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22defaultDocument%22%3C%2FSPAN%3E%20%3CSPAN%3EoverrideModeDefault%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22Deny%22%3C%2FSPAN%3E%20%3CSPAN%3E%2F%26gt%3B%3C%2FSPAN%3E%3CSPAN%3E%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CP%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20an%20application%20owner%20tries%20to%20set%20the%20default%20document%20in%20a%20%3CCODE%3Eweb.config%3C%2FCODE%3E%20file%2C%20this%20error%20message%20will%20be%20displayed%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EHTTP%20Error%20500.19%20%E2%80%93%20Internal%20Server%20Error%3C%2FSTRONG%3E%3CBR%20%2F%3E%20The%20requested%20page%20cannot%20be%20accessed%20because%20the%20related%20configuration%20data%20for%20the%20page%20is%20invalid.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20configuration%20section%20cannot%20be%20used%20at%20this%20path.%20This%20happens%20when%20the%20section%20is%20locked%20at%20a%20parent%20level.%20Locking%20is%20either%20by%20default%20(overrideModeDefault%3D%E2%80%9DDeny%E2%80%9D)%2C%20or%20set%20explicitly%20by%20a%20location%20tag%20with%20overrideMode%3D%E2%80%9DDeny%E2%80%9D%20or%20the%20legacy%20allowOverride%3D%E2%80%9Dfalse%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20648px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F63588i7B92B691D8B90C8B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%221.png%22%20title%3D%221.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20try%20to%20change%20the%20default%20document%20in%20IIS%20Manager%2C%20you%20will%20receive%20this%20error%20message%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20was%20an%20error%20while%20performing%20this%20operation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20configuration%20section%20cannot%20be%20used%20at%20this%20path.%20This%20happens%20when%20the%20section%20is%20locked%20at%20a%20parent%20level.%20Locking%20is%20either%20by%20default%20(%3CCODE%3EoverrideModeDefault%3D%E2%80%9DDeny%E2%80%9D%3C%2FCODE%3E)%2C%20or%20set%20explicitly%20by%20a%20location%20tag%20with%20%3CCODE%3EoverrideMode%3D%E2%80%9DDeny%E2%80%9D%3C%2FCODE%3E%20or%20the%20legacy%20%3CCODE%3EallowOverride%3D%E2%80%9Dfalse%E2%80%9D%3C%2FCODE%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20648px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F63590iC7B5EF8C27355D12%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%222.png%22%20title%3D%222.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--878793825%22%20id%3D%22toc-hId--792037593%22%3EallowDefinition%20attribute%3C%2FH2%3E%0A%3CP%3EUse%26nbsp%3B%3CCODE%3EallowDefinition%3C%2FCODE%3E%20attribute%20if%20you%20want%20to%20specify%20which%20configuration%20file%20can%20edit%20which%20tags.%3C%2FP%3E%0A%3CP%3EFor%20instance%2C%20if%20you%20want%20to%20allow%20server-level%20configuration%20and%20deny%20application-level%20configuration%2C%20here%20is%20the%20setting%20that%20should%20go%20to%20your%20%3CSPAN%3EapplicationHost%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Econfig%3C%2FSPAN%3E%20file%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CCODE%3E%3CSPAN%3E%3CSECTIONGROUP%3E%3C%2FSECTIONGROUP%3E%3C%2FSPAN%3E%20%3CSPAN%3Ename%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22system.webServer%22%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3CSPAN%3E%3CSECTION%3E%3C%2FSECTION%3E%3C%2FSPAN%3E%20%3CSPAN%3Ename%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22defaultDocument%22%3C%2FSPAN%3E%20%3CSPAN%3EoverrideModeDefault%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22Allow%22%3C%2FSPAN%3E%20%3CSPAN%3EallowDefinition%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22MachineToWebRoot%22%3C%2FSPAN%3E%20%3CSPAN%3E%2F%26gt%3B%3C%2FSPAN%3E%3CSPAN%3E%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20an%20application%20owner%20tries%20to%20set%20the%20default%20document%20in%20a%20%3CCODE%3Eweb.config%3C%2FCODE%3E%20file%2C%20the%20error%20message%20below%20will%20appear.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EConfiguration%20section%20can%20only%20be%20set%20in%20%3CCODE%3Emachine.config%3C%2FCODE%3E%20or%20root%20%3CCODE%3Eweb.config%3C%2FCODE%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20648px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F63591i32CBF1EC53ED103C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%223.png%22%20title%3D%223.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20error%20is%20displayed%20becasue%20we%20specified%20%3CSPAN%3EMachineToWebRoot%3C%2FSPAN%3E%20in%26nbsp%3B%3CCODE%3EallowDefinition%3C%2FCODE%3E%20attribute.%20It%20means%20that%20only%26nbsp%3B%3CCODE%3Emachine.config%3C%2FCODE%3E%2C%20%3CCODE%3EapplicationHost.config%3C%2FCODE%3E%2C%20and%20root%20%3CCODE%3Eweb.config%3C%2FCODE%3E%20file%20(the%20one%20in%20the%20same%20folder%20as%20%3CCODE%3Emachine.config%3C%2FCODE%3E)%20can%20override%20this%20setting.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20are%20other%20values%20for%20%3CCODE%3EallowDefinition%3C%2FCODE%3E%20attribute%20(%3CA%20href%3D%22https%3A%2F%2Fnam06.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fmsdn.microsoft.com%252Fen-us%252Flibrary%252Fmicrosoft.web.administration.sectiondefinition.allowdefinition(v%253Dvs.90).aspx%26amp%3Bdata%3D02%257C01%257CNedim.Sahin%2540microsoft.com%257C8ca55ff4206a4f3b82cc08d66535c1e6%257C72f988bf86f141af91ab2d7cd011db47%257C1%257C0%257C636807678897128889%26amp%3Bsdata%3De6QoCmwCz3HOuTD%252FtRAm9RL9spQGEA7YV3ZI7wQhqr4%253D%26amp%3Breserved%3D0%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESource%3C%2FA%3E%3A(%3C%2Fimg%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%E2%80%9CEverywhere%E2%80%9D%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EThe%20section%20can%20be%20defined%20in%20any%20configuration%20level.%20The%20default%20value.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%E2%80%9CMachineToApplication%E2%80%9D%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EThe%20section%20can%20be%20defined%20in%20the%20Machine.config%20or%20ApplicationHost.config%20file.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%E2%80%9CMachineOnly%E2%80%9D%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EThe%20section%20can%20be%20defined%20only%20in%20the%20Machine.config%20file.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%E2%80%9CMachineToWebRoot%E2%80%9D%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EThe%20section%20can%20be%20defined%20in%20the%20Machine.config%2C%20ApplicationHost.config%2C%20or%20Web.config%20file.%20The%20Web.config%20file%20is%20stored%20in%20the%20Web%20site%20root.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%E2%80%9CAppHostOnly%E2%80%9D%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EThe%20section%20can%20be%20defined%20only%20in%20the%20ApplicationHost.config%20file.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-305415%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EThere%20are%20two%20attributes%20that%20come%20handy%20if%20you%20want%20to%20enforce%20application%20settings%20in%20IIS%3A%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EoverrideModeDefault%3C%2FCODE%3E%3CSPAN%3E%20and%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EallowDefinition%3C%2FCODE%3E%3CSPAN%3E.%20%3C%2FSPAN%3EThis%20post%20explains%20how%20and%20when%20to%20use%20them.%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft

There are two attributes that come handy if you want to enforce application settings in IIS: overrideModeDefault and allowDefinition. If your users try to override settings when these attributes are used, they may see to see HTTP Error 500.19.

 

overrideModeDefault attribute

Example: If you don’t want anybody to change the default document in your IIS, use overrideModeDefault attribute in the applicationHost.config as the example below.

 

<sectionGroup name="system.webServer">  
<section name="defaultDocument" overrideModeDefault="Deny" /></sectionGroup>

 

If an application owner tries to set the default document in a web.config file, this error message will be displayed:

 

HTTP Error 500.19 – Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

 

This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”), or set explicitly by a location tag with overrideMode=”Deny” or the legacy allowOverride=”false”.

 

1.png

 

If you try to change the default document in IIS Manager, you will receive this error message:

 

There was an error while performing this operation.

 

This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”), or set explicitly by a location tag with overrideMode=”Deny” or the legacy allowOverride=”false”.

 

2.png

 

allowDefinition attribute

Use allowDefinition attribute if you want to specify which configuration file can edit which tags.

For instance, if you want to allow server-level configuration and deny application-level configuration, here is the setting that should go to your applicationHost.config file:

 

<sectionGroup name="system.webServer">   <section name="defaultDocument" overrideModeDefault="Allow" allowDefinition="MachineToWebRoot" /></sectionGroup>

 

When an application owner tries to set the default document in a web.config file, the error message below will appear.

 

Configuration section can only be set in machine.config or root web.config

 

3.png

 

This error is displayed becasue we specified MachineToWebRoot in allowDefinition attribute. It means that only machine.config, applicationHost.config, and root web.config file (the one in the same folder as machine.config) can override this setting.

 

Here are other values for allowDefinition attribute (Source:(

 

“Everywhere”

The section can be defined in any configuration level. The default value.

“MachineToApplication”

The section can be defined in the Machine.config or ApplicationHost.config file.

“MachineOnly”

The section can be defined only in the Machine.config file.

“MachineToWebRoot”

The section can be defined in the Machine.config, ApplicationHost.config, or Web.config file. The Web.config file is stored in the Web site root.

“AppHostOnly”

The section can be defined only in the ApplicationHost.config file.