System.Web.HttpException File does not exist - Page loads just fine (ASP.NET)
Asked Answered
T

3

13

I'm using Log4Net and logging everytime my ASP.NET-Application throws an error:

    protected void Application_Error(object sender, EventArgs e)
    {
        Exception ex = Server.GetLastError();
        Log.Error("An error occurred", ex);
    }

Alas, everytime I visit a page on my application, a System.Web.HttpException is caught, "File does not exist".

Here's the Stack Trace:

bei System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response)
bei System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context, String overrideVirtualPath)
bei System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state)
bei System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
bei System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I don't have any clue how to debug this, this happens on my ASP.NET Development Server and on an IIS 7.5 I deploy it on.

Trackandfield answered 1/3, 2012 at 14:20 Comment(0)
A
22

I bet it's the favicon.ico that Google Chrome always requests and which you forgot to include. But to be sure you could trace the request url:

protected void Application_Error(object sender, EventArgs e)
{
    Exception ex = Server.GetLastError();
    Log.Error("An error occurred", ex);
    Log.Error("Requested url: ", Request.RawUrl);
}

Now in your log file you should see:

Requested url: /favicon.ico

or something else like robots.txt when for example web crawlers attempted to crawl your site.

Abarca answered 1/3, 2012 at 14:21 Comment(4)
Yep, favicon.ico or robots.txt.Fab
As it turns out it was the favicon.ico that Google Chrome always requests and which I forgot to include.Taker
@DennisRöttger +1 Why did I encounter this error also , which is not found favicon.ico I was using Firefox . not chrome. thanks.Sidereal
This is a nice tip. I used HttpContext.Current.Request.Url instead of Request.RawUrlBeanery
M
0

I have same error:

There were some file references in CSS. That does not exist in directory. So it gave this error. I created Image Files, so error disappeared.

So make sure that file reference that you have given is exists in your directory

Melodie answered 18/1, 2014 at 6:9 Comment(0)
C
0

Check your HTML output of your page in case of using url with tilda "~/"

You need to use @Url.Content() to fix it

http://clubmicrosoft.net/post/2014/02/28/File-does-not-exist.aspx

Clone answered 27/2, 2014 at 21:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.