So I'm trying to add a 'ServerType' AppSetting. It works when I add it to a web.config.
web.config before:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
...
web.config after:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="ServerType" value="I AM A WEB.CONFIG OVERRIDING MACHINE.CONFIG" />
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
...
But I'm trying to do the same thing for the machine.config and it keeps throwing 500 errors.
machine.config before:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<configSections>
<section name="appSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=blahblah" restartOnExternalChanges="false" requirePermission="false" />
...
Attempt 1:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<configSections>
<section name="appSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=blahblah" restartOnExternalChanges="false" requirePermission="false" serverType="I AM MACHINE" />
...
Result:
The page cannot be displayed because an internal server error has occurred.
Attempt 2:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<configSections>
<section name="appSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=blahblah" restartOnExternalChanges="false" requirePermission="false">
<add key="ServerType" value="I AM MACHINE" />
</section>
...
Result:
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
(Which is odd because the web.config already has <customErrors mode="Off"></customErrors>
.)
Attempt 3:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<configSections>
<appSettings>
<add key="ServerType" value="I AM MACHINE" />
</appSettings>
<section name="appSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=blahblah" restartOnExternalChanges="false" requirePermission="false"/>
...
Result:
The page cannot be displayed because an internal server error has occurred.
Attempt 4:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<configSections>
<section name="appSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=blahblah" restartOnExternalChanges="false" requirePermission="false"/>
...
</configSections>
<appSettings>
<add key="ServerType" value="I AM MACHINE" />
</appSettings>
...
Result:
Service Unavailable
HTTP Error 503. The service is unavailable.
I'm clearly missing something fundamental here, but I haven't been able to figure out nor research what.
That appSettings
element needs to be added after the configSections
element.
machine.config :
<configuration>
<configSections>
<section name="appSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" />
<!-- More section definitions ... -->
</configSections>
<appSettings>
<add key="ServerType" value="I AM MACHINE" />
</appSettings>
<!-- More sections ... -->
</configuration>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.