开发者

Reading AppSettings value from web.config

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜