ERR_CONNECTION_RESET:上传大文件时连接被重置
我遇到了一个神秘错误,大于 4MB 的文件生成了随机错误。后来我意识到这是由于 http 引起的最大请求长度
。默认上传的图片不能大于4MB。
我知道这可以通过 web.config 文件进行更改。
当我尝试通过显示另一个页面来解决此错误时,开始弹出一个不同的错误。调试时,程序立即进入application_error。
执行Server.GetLastError()
时产生异常:
[System.Web.HttpUnhandledException] {“异常类型 “System.Web.HttpUnhandledException”是 抛出。”} System.Web.HttpUnhandledException
堆栈跟踪:位于 System.Web.UI.Page.HandleError(Exception e) 处 System.Web.UI.Page.ProcessRequestMain(布尔值 includeStagesBeforeAsyncPoint、布尔值 includeStagesAfterAsyncPoint) 在 System.Web.UI.Page.ProcessRequest(布尔值 includeStagesBeforeAsyncPoint、布尔值 includeStagesAfterAsyncPoint) 在 System.Web.UI.Page.ProcessRequest() 处 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext 上下文)位于 System.Web.UI.Page.ProcessRequest(HttpContext上下文)位于 ASP.businessprofile_aspx.ProcessRequest(HttpContext 上下文) 中 c:\Users\Mattew\AppData\Local\Temp\Temporary ASP.NET 文件\root\4ea30077\8f66786f\App_Web_h5fmhavk.4.cs:第 0 行 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤, 布尔&同步完成)
如果我尝试 application_error 方法中的任何代码(例如重定向),仍然是错误页面: 错误 101 (net::ERR_CONNECTION_RESET):连接已重置。 显示。
问题
应该如何处理此错误?可以提前处理吗?那么这个错误不显示吗? ( 我之前尝试过使用jquery获取文件大小并检查它,但我发现它太复杂了
如果问题 1 无法“回答”,有没有办法拦截此错误并显示友好错误?
I had a mysterious error where a file greater than 4MB generated a random error. Later on I realized it was caused due to the http maxrequestlength
. An image cannot be greater than 4MB when uploaded by default.
I know that this can change from the web.config file.
When I tried to cater for this error, by displaying another page, a different error started popping up. When debugging, the program enters application_error immediately.
When executing Server.GetLastError()
Exception generated:
[System.Web.HttpUnhandledException] {"Exception of type
'System.Web.HttpUnhandledException' was
thrown."} System.Web.HttpUnhandledExceptionthe stack trace: at System.Web.UI.Page.HandleError(Exception e) at
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest() at
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at
System.Web.UI.Page.ProcessRequest(HttpContext context) at
ASP.businessprofile_aspx.ProcessRequest(HttpContext context) in
c:\Users\Mattew\AppData\Local\Temp\Temporary ASP.NET
Files\root\4ea30077\8f66786f\App_Web_h5fmhavk.4.cs:line 0 at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)
If I try any code inside the application_error method, e.g. redirecting, still the error page:
Error 101 (net::ERR_CONNECTION_RESET): The connection was reset.
is displayed.
Questions
How should this error be handled? Can it be handled before hand? So this error is not displayed? ( I tried using jquery to get the file size before and check it but I'm finding it too complex
If Question 1 is not 'answerable', is there a way to intercept this error and display a friendly error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个。
在 web.config 中的系统 web 下
添加此行..
然后您需要检查文件大小
如果您发现它有用,请将其标记为您的答案,否则请告诉我..
Try this out.
Under system web in web.config
add this line..
Then you need to check the file size
If you find it useful, please mark it as your answer else let me know..