Guest User

Untitled

a guest
Aug 28th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. How to read a values from new section in web.config
  2. <configuration>
  3. <configSections>
  4. <section name="secureAppSettings" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  5. </configSections>
  6. <secureAppSettings>
  7. <add key="userName" value="username"/>
  8. <add key="userPassword" value="password"/>
  9. </secureAppSettings>
  10. </configuration>
  11.  
  12. string userName = System.Configuration.ConfigurationManager.secureAppSettings["userName"];
  13. string userPassword = System.Configuration.ConfigurationManager.secureAppSettings["userPassword"];
  14.  
  15. NameValueCollection section = (NameValueCollection)ConfigurationManager.GetSection("secureAppSettings");
  16. string userName = section["userName"];
  17. string userPassword = section["userPassword"];
Add Comment
Please, Sign In to add comment