Hashim's Blogs

Tuesday, April 18, 2006

How to Add Custom Tag in Web.Config Page (ASP.NET)

How to Add Custom Tag in Web.Config Page (ASP.NET)
To add a custom tag to Web.config you need to first explicitly specify the new tag name in Web.config via the tag
For Example:





type="System.Configuration.NameValueFileSectionHandler,
System, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />


...


This
tag indicates that we are going to be adding New tag named MyAppSettings.
Now we can add a tag to our Web.config file and
add tags to add application-wide parameters,
For Example:





type="System.Configuration.NameValueFileSectionHandler,
System, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />





...

How to Read Custom Tag

To read this custom value from an ASP.NET Web page we use the following syntax:

ConfigurationSettings.GetConfig("MyAppSettings")("connString")

0 Comments:

Post a Comment

<< Home