简体   繁体   English

哪里可以找到IIS管理器连接字符串的位置

[英]Where to find the location of IIS manager connection strings

I was getting an error saying that one of my connection string in my application's web.config file was already defined. 我收到一条错误消息,说我的应用程序的web.config文件中的连接字符串之一已经定义。

I checked in the IIS settings and when I checked the connection string property it was there already with Entry Type : Inherited. 我检查了IIS设置,当我检查了连接字符串属性时,它已经存在,并且具有Entry Type:Inherited。

So I went up the chain and went all the way up to the root of the localhost and checked the connection strings there. 因此,我上了链,一直到本地主机的根,并检查了那里的连接字符串。

I found a bunch of connection strings there as well.. but they're also all with Entry Type Inherited.. 我也在那里找到了一堆连接字符串..但是它们也都带有Entry Type Inherited ..

I checked the web.config file inside the wwwroot folder but didn't find any connection strings defined in there.. 我检查了wwwroot文件夹内的web.config文件,但未在其中找到任何定义的连接字符串。

Where could these connection strings be coming from?... 这些连接字符串从哪里来?

在此处输入图片说明

Configuration files in .NET are inherited in the following order: .NET中的配置文件按以下顺序继承:

  • systemroot\\Microsoft .NET\\Framework\\versionNumber\\CONFIG\\Machine.config
  • systemroot\\Microsoft .NET\\Framework\\versionNumber\\CONFIG\\Web.config (ASP.NET only) systemroot\\Microsoft .NET\\Framework\\versionNumber\\CONFIG\\Web.config (仅ASP.NET)
  • (application directory)\\Web.config

So the connection strings that show up as "inherited" are specified in either of the upper two files. 因此,在上方的两个文件中的任何一个中都指定了显示为“继承”的连接字符串。

Reference: MSDN: ASP.NET Configuration File Hierarchy and Inheritance 参考: MSDN:ASP.NET配置文件的层次结构和继承

If you don't want to alter the machine-wide configuration, you can <clear /> them from being inherited in your application's configuration as explained in What does <clear /> signify when specifying a connectionstring? 如果您不想更改计算机范围的配置,则可以<clear />它们在应用程序的配置中被继承,如<clear />在指定连接字符串时所表示的含义中所述。 :

<connectionStrings>
   <clear />
   <add name="LocalSqlServer" connectionString="..." /> 
</connectionStrings>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM