开发者

Reading AppSettings value from web.config

开发者 https://www.devze.com 2023-03-30 14:21 出处:网络
Here\'s my appSettings in the web.config: <appSettings> <add key=\"**Subdomain**\" value=\"england\" />

Here's my appSettings in the web.config:

<appSettings>
  <add key="**Subdomain**" value="england" />
</appSettings>

Inside the same web.config, I want to read this value:

<errorLog applicationName="**Subdomain**" />

Is there anyway to achieve this through something similar to: <%$ AppSe开发者_运维技巧ttings: MyAttribute %> ?


Why not just try using "england" for the value of the applicationName attribute? I think the purpose of having appSettings in the web.config file is to allow settings in the code files to be changed during runtime. However, you're using appSettings to change values that can already be changed during runtime. Plus, not using the appSettings dictionary for this purpose will cut down on the complexity of your configuration file.


Since web.config is an XML file you can use code like this to access it:

http://patelshailesh.com/index.php/update-web-config-programmatically

Ask if you have any more question.

0

精彩评论

暂无评论...
验证码 换一张
取 消