set and access global config vars in web.config


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <configuration>
  2. <appSettings>
  3. <add key="websiteName" value="My New Website"/>
  4. </appSettings>
  5.  
  6. Then, to use it, be sure to import:
  7. using System.Configuration
  8.  
  9. And in the body: System.Configuration.ConfigurationManager.AppSettings["websiteName"];
  10.  
  11. OR, in web form, just use Expression syntax:
  12. <asp:Literal Text="<%$AppSettings: websiteName %>" />

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.