Dharmik Bhandari Dharmik Bhandari - 3 months ago 13
ASP.NET (C#) Question

Child site uses parent site's connection string in ASP.NET 2.0

There are 5 websites in ASP.NET 2.0 which have the same code and database structure. The only difference is the CSS and site names. These all are hosted on single GoDaddy account.

For example:


  1. www.abc1.com

  2. www.abc2.com

  3. www.abc3.com

  4. www.abc4.com

  5. www.abc5.com



There is a main folder bound to www.abc1.com and four other sub-directories bound to the other four sites.

Problem is that:

When I remove connection string from web.config of www.abc4.com, it is still working.

At same time it uses www.abc1.com's connection string and remaining sites are working fine. If www.abc4.com has problem then all sites should be affected?

How is it possible?

Answer

This is because the connection string is inherited from the parent application's web.config.

You can forcefully specify to use the next added connection string to be used by inserting

<clear />

before you add new connection string.

This removes all references to inherited connection strings, allowing only the connection strings that are added by the current add element.

Refer http://msdn.microsoft.com/en-us/library/ayb15wz8.aspx for MSDN docs on this.