繁体   English   中英

System.Web.HttpException文件不存在 - 页面加载很好(ASP.NET)

[英]System.Web.HttpException File does not exist - Page loads just fine (ASP.NET)

每次我的ASP.NET-Application抛出错误时,我都在使用Log4Net并进行日志记录:

    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上我部署它。

我打赌这是Google Chrome总是要求的favicon.ico ,而你忘了包含它。 但是要确保您可以跟踪请求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 ,例如网页抓取工具尝试抓取您的网站时。

我有同样的错误:

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

因此,请确保您所提供的文件引用存在于您的目录中

如果使用带有tilda的网址“〜/”,请检查您网页的HTML输出

您需要使用@ Url.Content()来修复它

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM