开发者

File not found exception in Application_Error

开发者 https://www.devze.com 2023-01-27 18:55 出处:网络
Hi all i am new in asp.net mvc. Sometimes i have an exception in Application_Error and i write it to my log file:

Hi all i am new in asp.net mvc. Sometimes i have an exception in Application_Error and i write it to my log file:

Error in  global.asax
System.Web.HttpException: File does not exist.
   at System.Web.StaticFileHandler.ProcessRequestForNonMapPathBasedVirtualFile(HttpRequest request, HttpResponse response)
   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.HttpAppli开发者_运维知识库cation.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I trying debug but i not see file name? How to see witch file cannot be found ? Thanks


when you debug, can you see in the request that the request is for a resource like an image, js file or something like that?

i sometimes get this messages when i get a request for an image (maybe referenced in a css file) which does not exists.


Add following method in Global.asax file

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

Request.RawUrl Give exact url which give an Error.

Now in your log file you should see:

Requested url: /favicon.ico
0

精彩评论

暂无评论...
验证码 换一张
取 消