How to Properly Configure web.config Connection String and Source

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

Tags: , , , , , , , , , , , | Posted under ASP .NET 3.5, DotNet/Windows Hosting | RSS 2.0

Author Spotlight

Rodolfo Hernandez

Rodolfo Hernandez

I like photography and reading books. Currently working for Arvixe as Elgg Community Liaison. Elgg Security Expert Web Security Expert CEO of UDP SW Social Web

3 Comments on How to Properly Configure web.config Connection String and Source

  1. Ehud says:

    you’ve wrote:
    ” InsertServerNameHere ”

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

  2. 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 says:

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

Leave a Reply

Your email address will not be published. Required fields are marked *


+ 6 = 11

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>