在 Application_Error() 中使用以下错误处理:
protected void Application_Error()
{
Exception exception = Server.GetLastError();
Response.Clear();
HttpException httpException = exception as HttpException;
if (httpException != null)
{
string action;
switch (httpException.GetHttpCode())
{
case 404:
// page not found
action = "HttpError404";
break;
case 500:
// server error
action = "HttpError500";
break;
default:
action = "General";
break;
}
// clear error on server
Server.ClearError();
Response.Redirect(String.Format("~/Error/{0}/?message={1}", action, exception.Message));
}
}
在添加这个之前,我的页面渲染得很好。现在我已经添加了这个,我得到了大约 21 个文件未找到异常。我最初认为某些路由值是错误的(但在您尝试路由之前它们不会执行),将它们注释掉,同样的事情。
我逐步完成了初始页面加载,并且由于整个页面一次呈现,我无法追踪这些来自哪里,并且堆栈跟踪没有给我我正在寻找的东西:
在 System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response)
在 System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context, String overrideVirtualPath) 在 System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback 回调, 对象状态) 在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤,布尔&完成同步)
我认为这可能发生在定义 CSS 和脚本的地方,但是将这些注释掉并不能解决问题。
我怎样才能找到这个?