指定连接字符串时 <clear /> 表示什么?

haw*_*bsl 6 asp.net connection-string

这个对另一个问题的回答指出:


不要忘记首先清除连接字符串:

<connectionStrings>
   <clear />
   <add name="LocalSqlServer" connectionString="Data Source=(local);Initial Catalog=aspnetdb;Integrated Security=True" providerName="System.Data.SqlClient"/> 
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)

... 有趣的。那有什么作用?

Run*_*tad 7

在 .Net 中,配置文件是继承的,因此您的应用程序配置将从您的计算机配置继承设置。

<clear/>标记将删除任何继承的连接字符串,从而避免混乱和潜在问题。

在 ASP.Net 中,您可能有多个继承的连接字符串,因此这在那里很常见。