2012-03-01 17 views
11

我使用log4net的和记录每次我的ASP.NET的应用程序抛出一个错误:System.Web.HttpException文件不存在 - 页面加载就好了(ASP.NET)

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

唉,每次我访问了我的应用程序中的一个页面,System.Web.HttpException被捕获,“文件不存在”。

这里的堆栈跟踪:

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) 

我没有任何线索如何调试这一点,这种情况我的ASP.NET开发服务器上和在IIS 7.5我将它部署。

回答

21

我敢打赌,它的favicon.ico,谷歌Chrome浏览器始终请求而您忘了。但可以肯定的,你可以跟踪请求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); 
} 

现在,在你的日志文件,你会看到:

Requested url: /favicon.ico 

或别的东西,像robots.txt时,例如网络爬虫尝试抓取您的网站。

+0

是的,或的favicon.ico robots.txt的。 – 2012-03-01 14:22:44

+1

事实证明,这是谷歌浏览器总是要求的“favicon.ico”,而我忘记了它。 – 2012-03-01 15:31:39

+1

@DennisRöttger+1为什么我还遇到这个错误,这是我没有找到'favicon.ico'我正在使用Firefox。不是铬。谢谢。 – 2013-07-11 02:29:16

0

我也有同样的错误:

在CSS中有一些文件引用。这在目录中不存在。所以它给了这个错误。 我创建了图像文件,所以错误消失了。

因此,请确保您已经给定文件引用是存在于你的目录