Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the web.config file settings override IIS settings?

Tags:

asp.net

iis

For example,

I can specify the session timeout in the web.config file by adding:

<system.web>
        <sessionState timeout="10"/>
</system.web>

Or I can configure the session timeout in IIS by going to the Application Configuration Options.

If they are both configured to different values, which one wins? And more specifically, do all other settings follow the same pattern?


EDIT: I don't see them being as one in the same. The web.config wins. And when I change the value in IIS, nothing gets written back to the web.config.

There's a definite disconnect between the settings in the web.config and the settings in IIS. I haven't read any good documentation on which one overrides the other. All I've observed is that the web.config wins. I thought someone else may have some more insight into this disparity.

like image 282
Aaron Daniels Avatar asked Aug 07 '09 18:08

Aaron Daniels


4 Answers

Too late to answer but may clear things up for future people who get here.

This article explains inheritance between IIS and ASP.net applications.

Quote from Tip 3: Understand how your Web.config inherits IIS configuration settings

Of course, server administrators don't necessarily want to allow any application on the server to modify settings via Web.config, so there are configurable policies in the ApplicationHost.config which state whether individual applications can override settings.

This post explains the usage of two ApplicationHost.config attributes: overrideModeDefault and allowDefinition. Both of these attributes set whether and who can override IIS settings which are inside ApplicationHost.config.

Based on those two, we cannot say undoubtedly that web.config overrides IIS, if we are not aware about ApplicationHost.config entries.

Quote from: Introduction to ApplicationHost.config

Most IIS sections are locked down by default, using overrideModeDefault="Deny" in the section.

like image 134
Fotis Papadamis Avatar answered Sep 18 '22 16:09

Fotis Papadamis


The one in web.config 'wins'.

Edit: Basically when you edit settings from UI the changes are written back to web.config

like image 12
AlexS Avatar answered Sep 18 '22 11:09

AlexS


They are one in the same.

like image 5
YetAnotherDeveloper Avatar answered Sep 21 '22 11:09

YetAnotherDeveloper


Settings configured in the IIS Manager are added to the root applicationHost.config file for your server (located in C:\Windows\System32\inetsrv\config) as <location path="your-site/subfolder"> elements. Since settings in a web.config always override those in the applicationHost.config, if the same setting has one value in the IIS Manager and another in your web.config, the web.config value 'wins'.

like image 5
david Avatar answered Sep 19 '22 11:09

david