开发者

ASP.NET MVC+ELMAH - Controller methods taking a very long time to respond when an exception occurs

开发者 https://www.devze.com 2023-02-16 08:22 出处:网络
I\'m working with a web application I built in ASP.NET MVC. It is deployed to IIS 7, and I have it configured to log exceptions with ELMAH.

I'm working with a web application I built in ASP.NET MVC. It is deployed to IIS 7, and I have it configured to log exceptions with ELMAH.

The problem I'm facing is that when an exception occurs in a controller method, it takes 15-20 (or more) seconds to res开发者_开发技巧pond to the HTTP request, even if it's an exception that I'm catching/logging. So the user is left sitting there forever wondering what's wrong with the site. This occurs over all sorts of exceptions; the common thread seems to be that the problem appears if an exception occurs in a controller method.

Has anyone ever seen this problem?

Note: I am running WinServer 2008 x64, ASP.NET MVC 2, .NET 4.0, IIS7, ELMAH 1.1, and debug is set to False in Web.Config. This didn't used to happen a while ago; I don't know what I might have changed to cause this to start happening.


Ok, that was fast. I figured it out.

The database ELMAH was using to store errors was moved to a different server, and I forgot to update Web.Config with the new connection string. So it was waiting for the error logging database connection to time out before returning the HTTP response to the user.

Now, with the correct connection information, exceptions are returning quickly like they used to.


A couple of ideas to get you moving:

  1. Can you duplicate this problem on your local development machine?
  2. Have you tried to use Visual Studio Performance Profiling (with instrumentation) to isolate where the lag occurs?

That's what I would do to track down the issue. Their performance profiling takes some getting used to but it provides excellent data.

0

精彩评论

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