Application_error 函数间歇性地捕获“文件不存在”
我使用 Application_Error
事件来处理异常,它可以正确捕获几乎所有异常。然而,在某些页面中,它捕获异常“文件不存在”,并且我无法找到它确切发生的位置。当我评论 Application_Error
代码时,令人惊讶的是该网页运行良好。
我主要关心的是如何追溯到它抛出到 Application_Error
函数的代码行。
I am using the Application_Error
event for handling the exceptions and it catches almost all exceptions correctly. However in some pages it catches with exception "File does not exist" and I am not able to find from where it exactly occurs. When I comment the Application_Error
code, surprisingly that web page works fine.
My main concern is how can trace back to the line of code from where it threw to Application_Error
function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 HttpContext.Current.Request.Url.ToString() 来查看丢失文件的文件路径。
Use
HttpContext.Current.Request.Url.ToString()
to look at the file path of the missing file.hoooo......刚刚解决了我的问题。在调试过程中,我在 Appilcation_Error 代码中放置了一个检查点,当执行到达该检查点时,我可以看到当时正在加载并导致异常的图像路径(路径错误)。 :)
hoooo....... just now solved my issue. During my debugging I had put one checkpoint in Appilcation_Error code and when execution reached it I could see the path of an image (path was wrong) which was loading at that time and which causes the exception. :)
就我而言,在 Jquery 中,很多地方都使用了背景图像 uri 和 uri 。那不存在,这就是为什么会出现这种类型的错误。
Right in my case also in Jquery at lots of place used backgroung image uri & that did not exist, thats why this type of error.
要查看问题,请在 Global.asax 的 Application_Error 事件上放置:
To see the problem, on Application_Error event of Global.asax put: