protected void Application_BeginRequest(object sender, EventArgs e)
{
const int maxFileSizeKBytes = 10240; //10 MB
const int maxRequestSizeKBytes = 305200; //~298 MB
if (Request.ContentLength > (maxRequestSizeKBytes * 1024))
{
Response.Redirect(".aspx?requestSize=" + Request.ContentLength.ToString());
}
for (int i = 0; i < Request.Files.Count; i++)
{
if (Request.Files[i].ContentLength > (maxFileSizeKBytes * 1024))
{
Response.Redirect(".aspx?fileSize=" + Request.Files[i].ContentLength.ToString());
}
}
}
此代码位于Global.asax.cs页面中。 我需要重定向到触发此检查的页面。我需要知道ticketId或projectId参数。例如,我在查看项目页面/Project/ViewProject.aspx?projectId=1
上创建新票证,我需要用一条有意义的消息重定向到此页面,因为我认为重定向到另一个页面以显示错误消息不是一个好主意。重定向应用程序级错误处理程序