I have a Web.config
file in my .NET Framework app hosted on IIS. Inside the Web.config
, I have a location
element like so:
...
<location path="Controllers/api">
<appSettings>
<add key="secrectMessage" value="myAwesomeValue"/>
</appSettings>
<system.web>
<httpRuntime executionTimeout="300"/>
</system.web>
</location>
...
secretMessage
is just for testing, what I really want is the timeout.
My goal is to have the executionTimeout
apply to only one API controller file, or even just one endpoint if possible. (I could split out that endpoint to its own file if files are as specific as Web.config
will go.) Using the structure above, when I go to IIS Manager and navigate to the Controllers/api
folder, and click Application Settings, I am able to see the secretMessage/myAwesomeValue
. Does this mean that the executionTimeout
is also set at this directory? I don't see any confirmation of that in the Manager UI.
When I change the path
value to "Controllers/api/MyController.cs"
I can't confirm the setting in the Manager UI because I can only navigate to directories. (It seems like every example of <location>
has an .aspx
file. Is there a reason for this?) Would changing the path to include the .cs
file work to change the settings on calls made to this controller? Is there a way to specify Web.config
settings for just one endpoint inside the controller?
Edit: I came up with another idea, which is to break the controller into two partial class
files, one inside an addition directory Controllers/api/extendedTimeout
to be able to apply the config to that directory. This seems to have done the same thing as far as I can tell in IIS Manager. Though, in the C# in Controllers/api/extendedTimeout/MyControllerExtension.cs
, I have `ConfigurationManager.AppSettings["secrectMessage"];' but this returns null.