当用户尝试上传对服务器来说太大的文件时,我试图更优雅地出错。但是,当我尝试捕获 Global.asax.cs 中的错误时,它似乎跳过了我的重定向代码。这是我所拥有的核心。
protected void Application_Error(object sender, EventArgs e)
{
HttpContext.Current.ClearError();
Response.Redirect("CustomErrors.aspx", false);
Context.ApplicationInstance.CompleteRequest();
}
我到处寻找的“答案”似乎是为了清除错误,但我已经这样做了。还有什么可能出错的。有任何想法吗?