Error Logging and Google Chrome 9.0
Today I created an ASP.NET MVC 3 default Web Application with the intention of testing a couple of ideas I had, without making a mess of any actual ‘live’ projects.
Once the application had been created the next thing I did was to use (the brilliant) NuGet to install the (also brilliant) ELMAH error logging facility. I then ran the application and had a browse around by typing URLs into the Google Chrome Omnibox (Address Bar to you and me). I was somewhat surprised when I browsed to elmah.axd to see a whole bunch of errors, particularly as I hadn’t even had a chance to break anything yet!
I then recalled the checkbox I had ticked in the Options dialog in Chrome 9 to ‘Enable Instant for faster searching and browsing’.
It seems that, if I am not fast enough when typing URLs into the address bar, Chrome requests pages from my application that don’t exist and these are being logged by ELMAH. In fact, you can catch a brief glimpse of a 404 as you type, if you get the timing right. A quick test by disabling ‘Instant’ proves this theory.
This will (should!) not be a problem for deployed sites, but is annoying for locally hosted applications as it makes it hard to ‘see the wood for trees’. If you are desperate to keep ‘Instant’ enabled you can, if you like, filter out the ‘not found’ errors programmatically during development with the following code:
void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
{
if (Request.IsLocal)
{
if ((e.Exception.GetType() == typeof(HttpException)) && (((HttpException)e.Exception.GetBaseException()).GetHttpCode() == 404))
e.Dismiss();
}
}
You must bear in mind though that it you use this code it will filter out ALL 404 errors on the local machine during testing, so you should use another strategy to compensate for this.













Surely they’re just HEAD requests and not full GET requests, couldn’t you filter it that way?