[英]Access web.config key from codebehind
I have a key in the web.config file like: 我在web.config文件中有一个键,如:
<add key="MailFrom" value="my@email.com"/>
I need to access it in the code behind.How to do this in c#? 我需要在后面的代码中访问它。如何在c#中执行此操作?
您可以使用AppSettings属性索引器:
string from = ConfigurationManager.AppSettings["MailFrom"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.