所以我正在尝试添加一个"ServerType"AppSetting。当我将它添加到web.config时,它就起作用了。
web.config之前:
<?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之后:
<?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>
...
但我正在尝试对machine.config做同样的事情,它不断抛出500个错误。
machine.config之前:
<?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" />
...
尝试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" />
...
结果:
由于发生内部服务器错误,无法显示页面。
尝试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>
...
结果:
运行时错误
描述:服务器上出现应用程序错误。此应用程序的当前自定义错误设置阻止远程查看应用程序错误的详细信息(出于安全原因(。然而,运行在本地服务器机器上的浏览器可以查看它。
(这很奇怪,因为web.config已经有<customErrors mode="Off"></customErrors>
。(
尝试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"/>
...
结果:
由于发生内部服务器错误,无法显示页面。
我显然错过了一些基本的东西,但我还没能弄清楚或研究什么。
需要在configSections
元素之后添加appSettings
元素。
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>