Introduction
Every .NET developer may have used the following tags available in the Web.Config file while developing web applications, using the ASP.NET Framework.
- AppSettings
- ConnectionStrings
AppSettings
These are used to store some configurable items. Below are a few of the examples.
- SMTPServer Details
Create configurable values for SMTP Server, Username, and Password. In production, you can even store encrypted passwords in Web.Config. - Path
Path of some template files or log files that could change in different environments.
You could use AppSettings key for storing anything that you would like to configure later, without making any changes to the code.
ConnectionStrings
These are used for storing the complete ConnectionStrings.
For example - The ConnectionString of SQL Server.
Both the above tags and related attributes are very helpful for developers, architects, and IT Administrators for configuring different values for different environments.
However, one of the disadvantages of these files is that as an IT Administrator or Architect, you would need to understand the syntax of these tags along with their attributes. You might not have the required tools to use the advantages, like Intellisense in the staging or production environments. As a result, you need to depend on your developers to make changes to the configuration files each time you want to deploy on a new environment.
Sometimes, you might not like to reveal your credentials to developers. In this article, we will learn how to overcome this issue using the AppSettings and ConnectionStrings settings of the Application Settings blade of the Azure App Service.
Below is an example of how to use AppSettings in an MVC application.
- Declare an AppSetting in Web.Config file.
- <appSettings>
- <add key="SMTPServerName" value="MySMTPServerfromWeb.Config"/>
- </appSettings>
- Use the App Setting variable in your Action Method – Please note that for simplicity.
- public string Index() {
- ViewBag.Title = "Azure Application Settings - Example";
- return "This is the Configurable Value in Web.Config for my SMTP Server: " + ConfigurationManager.AppSettings["SMTPServerName"];
- }








Join the conversation! Your thoughts help the community grow.