Now, I'm not sure how many of you log your exceptions (caught/un-caught) within your ASP.NET web application. If you don't, get a little closer so I can smack you! ;-)
<designRant>
Logging your exceptions gives you the advantage of having more information related to the inconsistancy in a common place, ie. flat file, db, etc.
</designRant>
Ok, for those of you that DO log, I'm not sure if you are aware of this interesting feature of VS.NET 2003. If you run VS.NET 2002, or another IDE, stop reading now.
Currently, I use log4net as my logging component, why? Well, I'm used to using it's Java counter part log4J from my previous life. Anyway, while looking through my logs, I found the following exception being logged:
Exception: System.Web.HttpException
Message: Exception of type System.Web.HttpException was thrown.
Source: System.Web
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, String path, String pathTranslated, Boolean useAppConfig)
at System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Nested Exception
Exception: System.IO.FileNotFoundException
Message: c:\inetpub\wwwroot\SprintExperience\get_aspx_ver.aspx
Source: System.Web
at System.Web.UI.TemplateParser.GetParserCacheItem()
at System.Web.UI.TemplateControlParser.CompileAndGetParserCacheItem(String virtualPath, String inputFile, HttpContext context)
at System.Web.UI.TemplateControlParser.GetCompiledInstance(String virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageParser.GetCompiledPageInstanceInternal(String virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String path)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, String path, String pathTranslated, Boolean useAppConfig)
The interesting part of this exception is that it's a System.IO.FileNotFoundException for the get_aspx_ver.aspx file. You might be asking, why is this file being referenced? Well, ask VS.NET 2003! This file is internally used by VS.NET to figure out your current version of ASP.NET (hence the file name). The reason why you never see this exception bubble up is cause it's internally caught/handled by VS.NET. However, this exception still triggers the OnError event handler, the method where my loggin information is hosted.
Fix it, fix it, fix it! Well, there is no fix...just a simple work around for your logging code. First, on your logging method, check if the requested file (via the Request.PhysicalPath property) is the "get_aspx_ver.aspx" file. If it is, ignore the exception. That's it!
Will there be a patch from MS for VS.NET? I don't think so...but now you know the rest of the story. For more information on this error, check google.