Loading any MVC page fails with the error “An item with the same key has already been added.”

后端 未结 2 868
南旧
南旧 2021-01-07 14:16

I am having an intermittent issue that is appearing on one server only, and is causing all MVC pages to fail to load with the error \"An item with the same key has already b

2条回答
  •  臣服心动
    2021-01-07 14:37

    If anyone is interested, I've solved this (I think) in a very hacky kind of way... What I've done is wire up to the Application_Error event in global.asax, and then check to see if the Server.GetLastError() exception (or its inner exception) contains the details of the error that is thrown (see full stack trace in the question). If it does, I then call for an app domain restart using the method found in this article: http://www.west-wind.com/weblog/posts/2006/Oct/08/Recycling-an-ASPNET-Application-from-within (basically using HttpRuntime.UnloadAppDomain(); or if that doesn't work by touching the web.config file.

    I need a shower...

提交回复
热议问题