How to Properly Configure web.config Connection String and Source

Written by Rodolfo Hernandez Monday, 1 October 2012

Some of our users were facing connection problems after deploying their Asp application in our servers. This was due to the fact of a bad web.config configuration. In this article, I will give you a step by step guide on how to properly configure web.config to work with your ASP application.

Web.config file is the main configuration settings for a Web application in ASP.NET. The file is an XML document that defines configuration information regarding the web application. The web.config file contains information that control module loading, security settings, configurations session state, compile and the language of the application. Web.config files can also contain specific objects such as connection strings to the database.

First, let’s Initialize the file:

<?xml version=”1.0″?>

<configuration>

</configuration>

Inside the tag “configuration”, we locate the content of our web.config. If you are deploying an Asp application in our servers, the correct format for the data connection string is the following:

<?xml version=”1.0″?>

<configuration>

<connectionStrings>

<add name=”MyDataBaseConnectionString_Name” connectionString=”Data Source=&quot;InsertServerNameHere&quot;;

Initial Catalog=MyDataBase; Integrated Security=false; User ID=myUSER; Password=mypassword”

/>

</connectionStrings>

</configuration>

Notice how the server name is inside quotes. Usually you write them like this (“”) however, for setting up the data connection source in the web.config file, those have to be written like this:

&quot;

The connection string should be the same that you use on your Asp Application. Make sure they match or your application will not work.

This concludes how to properly configure web.config connection string and source

Looking for quality Asp Hosting? Look no further than Arvixe Web Hosting!

Happy Hosting!

Rodolfo Hernandez



3 Comments

  1. Ehud   |  Tuesday, 13 November 2012 at 5:05 am

    you’ve wrote:
    ” InsertServerNameHere ”

    I’m trying to use a MS SQL server on arvixe. What is the server name.

  2. Rodolfo Hernandez   |  Tuesday, 13 November 2012 at 6:38 am

    It’s in your welcome email.
    If you don’t have it, you can login to your billing account and click on past notifications.

  3. garyxiao   |  Tuesday, 14 May 2013 at 11:23 am

    wow.Sets the provider and connection string for the data source..thx very much

Leave a Reply






− two = 1