HttpException: File does not exist

Since some time I happened to get a nasty exception in the global.asax Application_Error method. Exception details are below:

Type : System.Web.HttpException
Message : File does not exist.
Source : System.Web
ErrorCode : -2147467259
Data : System.Collections.ListDictionaryInternal
TargetSite : Void ProcessRequestInternal(System.Web.HttpContext)
Stack Trace :
at System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context)
at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

After some hard time trying to resolve this bug, I finally figured out what the problem was. The problem related to this exception is an HttpRequest to a non-existing source, not being the main request, but something like an image or iframe source. In my case, it was an iframe source loaded with a non-existing document.

To resolve this exception at your place, add the following to your Watch window: ((HttpApplication)sender).Context.Request.Url and set a breakpoint on the Application_Error method. This way, the exception will clarify itself a lot (it definitely did for me).

24 thoughts on “HttpException: File does not exist

  1. Anonymous

    Thanks! Depening on your config you may have to qualify the HttpApplication – ((System.Web.HttpApplication)Sender).Context.Request.Url – Problem was the favicon.ico. Never would hae figured that out without your help

  2. Bert Loedeman Post author

    @Bob
    Sorry for being late on answering. Problem is that I’m running at some deadlines ;)

    The URL in the watch is the URL of the file the system cannot find, therefore, in my opinion that still equals the file that cannot be found ;) .

    Hope that helps!

  3. Bob

    I’m having the same problem but I’m not seeing how your solution fixes it. Lot’s of ppl are on here thanking you which tells me I’m missing something.

    I can’t figure out what file my system cannot find.

    Is there a specific property under ((HttpApplication)sender).Context.Request.Url that shows the missing file?

  4. Faisal Fareed

    thanks a lot bert… my database table was just filling up madly with this exception… it helped a lotttttttt again thanks :)

  5. Anonymous

    YOU F’ing ROCK DUDE! I been trying to figure this one out for awhile!!
    BERT IS DA MAN!!!!!!!
    WOOHOO!! Thanks my friend!!!

  6. Anonymous

    In many cases this misterious file is “favicon.ico”
    (I got ‘http://localhost:5086/favicon.ico’ while debugging)

    Just add any empty icon into website root directory if you have no

  7. Anonymous

    THANK YOU!!!!

    I had this problem for a long time, and now it’s resolved!

    I’m your fan now =)

    Sleza4e

Comments are closed.