Jared Jared - 1 year ago 112
ASP.NET (C#) Question

ASP.NET Connection String error when deployed on GoDaddy

I have an ASP.NET app that accesses a SQL Server database with membership and roles tables included. The app works perfectly when run locally, but when I deploy it to a shared Godaddy host, write operations on the database seem to act funny. I added before my connection strings in web.config to see if the app was trying to access a different database, and I got the following error in machine.config (which I have no control over since it is a shared host):

The connection name 'LocalSqlServer' was not found in the applications configuration or the
connection string is empty.

Any ideas about what might be causing this to happen?

Answer Source

This is because you are referencing LocalSqlServer somewhere. You must have this in YOUR machine.config. That is why it doesn't complain on your PC. This is usually because your Membership or Role section in your web.config references a provider which then in turn references a connection string. And the default connection string name is "LocalSqlServer". So you should comment out this connection in your machine.config to troubleshoot. Also clear all the providers in your web.config.

<membership defaultProvider="MyOnlyMembershipProvider">
           <add name="MyOnlyMembershipProvider" 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download