15 September 2010

File Not Found Exception in Application_Error of Global.asax

I got this nasty error of "File Not Found." in Application_Error of Global.asax file on every web page request of my web application in ASP.NET. I try to check what is causing this File Not Found exception on every single request. Initially I try to catch the exception and check what is stack trace is saying but that is of not much help as there wasn't any indication what is causing it. Then I found the solution. Here it is for those who are trying to resolve it. Save some of your productive hours.

Step 1 : Set break point at Application_Error of Global.asax .

Step 2 : Start debugging your application and when the request hit the Application_Error break point type

 ((HttpApplication)sender).Context.Request.Url  

into Watch window of visual studio.

This will give you the information on which resource is missing and why this specific exception is generated on every single request.

Happy Coding !!!