Web.config is a XML file containing the configuration settings of our application. Amongst its other uses, the file is extremely handy when it comes to changing configuration settings of an application, even when the application is live. You can define your own specific application settings, such as a database connection string using the <appSettings> tag and read and write values to the file programmatically. In this article, we see how to read the configuration settings in the web.config using ‘JavaScript’.
ASP.NET provides the Web Site Administration Tool to view and manage the configuration settings for your ASP.NET website. These configuration settings are stored in an xml file called web.config.
In this short article, I will see how we can retrieve the values from the <appSettings> and <connectionStrings> section in the web.config using JavaScript. So let us get started.
Step 1: Create a new ASP.NET website. Add a button control to the Default.aspx.
<configuration>
<appSettings>
<addkey=“var1“value=“SomeValue“/>
</appSettings>
<connectionStrings>
<addname=“MyConnString“connectionString=“Data Source=(local);Initial Catalog=Northwind;Integrated Security=True;“/>
</connectionStrings>
I hope you liked this short article and I thank you for viewing it. If you liked the article,
then please comment it or give me suggestion to make more effective.
