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).

If you like this blog post, you can easily share it:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • DotNetKicks
  • Technorati
  • Twitter
  1. Anonymous
    November 28th, 2008 at 08:51 | #1

    thank you!

  2. Bert Loedeman
    November 28th, 2008 at 14:20 | #2

    You’re welcome :) !

  3. Anonymous
    December 4th, 2008 at 18:03 | #3

    Thank you!

  4. Anonymous
    December 17th, 2008 at 18:57 | #4

    Thank you very much! This was very helpful.

  5. Joel
    January 2nd, 2009 at 16:52 | #5

    This was helpful to me. Thank you.

  6. Anonymous
    January 14th, 2009 at 11:16 | #6

    THANK YOU!!!!

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

    I’m your fan now =)

    Sleza4e

  7. Anonymous
    January 14th, 2009 at 11:27 | #7

    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

  8. Chirag Davda
    January 16th, 2009 at 01:47 | #8

    THANKS A LOT :)

  9. Anonymous
    January 23rd, 2009 at 11:21 | #9

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

  10. ab
    August 5th, 2009 at 13:15 | #10

    Thanks a lot!!

  11. Gulshan
    September 1st, 2009 at 14:14 | #11

    Thanks a Lot.

  12. Gulshan
    September 1st, 2009 at 14:15 | #12

    Thanks a lot !!!

  13. Faisal Fareed
    September 3rd, 2009 at 04:43 | #13

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

  14. Anonymous
    November 16th, 2009 at 05:40 | #14

    Thanks. This was quite annoying to find!

  15. Khayman
    January 18th, 2010 at 06:50 | #15

    THANK YOU! Damn that was annoying me

  16. OMG
    June 8th, 2010 at 02:45 | #16

    THANK YOU! :)

  17. Anonymous
    June 11th, 2010 at 10:17 | #17

    You rock! Thanks for sharing, excellent tip.

  1. No trackbacks yet.