开发者

ASP.Net/web.config - "The entry 'x' has already been entered"?

开发者 https://www.devze.com 2023-01-17 21:42 出处:网络
In ASP.Net when I see the error message \"The entry \'x\' has already been entered\" I think that means a 开发者_Go百科name (in this case \'x\') is defined twice in Web.Config.

In ASP.Net when I see the error message "The entry 'x' has already been entered" I think that means a 开发者_Go百科name (in this case 'x') is defined twice in Web.Config.

Is that a reasonable summary of what causes that error or are there other ways it could be generated ?

The 'x' in question doesn't appear twice in the web.config - any ideas of what else could be causing this error ?


If you have nested web.config files, the same connection string entry in both web.config files can cause this error. You can fix this by adding a <clear/> tag in the nested web.config file like so:

<connectionStrings>
    <clear/>
    <add name="MyEntities" connectionString="blah,blah,etc." />
</connectionStrings>


It could be you have nested Web.configs. If you're running more than one application out of the same directory hierarchy you might see this. For example, say you've got IIS pointed at the root of some directory, but inside that directory is a folder with another app in it and you have a vdir pointed to that app - well you may indeed run in to this problem as ASP.Net will parse the web.config at the root first, and then the web.config for the application the vdir points to.


+1 to Erics answer. Also if you upgrade web projects (i.e. from VS 2008 to VS 2010) the web.config file it keeps for you in the backup folder will cause this error for the same reason.


I've seen this happen where the virtual directory inherited settings from the root site. Check to see if another web.config at the parent level does not also contain the AppSettings key.

0

精彩评论

暂无评论...
验证码 换一张
取 消