What does this error mean? The remote host closed the connection. The error code is 0x80070057

匿名 (未验证) 提交于 2019-12-03 00:50:01

问题:

Even though a couple people have asked this question it seems there problem is different than mine. Like most of them seem to get line numbers or the problem might be caused with ViewState.

I am using Asp.net 4.0 MVC 2.0 so I don't think I am using ViewState at all. My error does not give me line numbers are well. So I have no clue what is causing it or where in my code.

System.Web.HttpException (0x80070057): The remote host closed the connection. The error code is 0x80070057.    at System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)    at System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush()    at System.Web.HttpResponse.Flush(Boolean finalFlush)    at System.Web.HttpResponse.Flush()    at System.Web.HttpResponse.End()    at System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent)    at System.Web.HttpResponseWrapper.Redirect(String url)    at MySolutionFile.Domain.RequiresSSL.OnActionExecuting(ActionExecutingContext filterContext)    at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)    at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c()    at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)    at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c()    at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)    at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)    at System.Web.Mvc.Controller.ExecuteCore()    at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)    at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)    at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__4()    at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()    at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()    at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)    at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

Anyone know why?

回答1:

Server couldn't send the answer to the client. Network connection lost on the client could be a cause.

Not sure if closing the browser/tab at the very precise time would also give the error.



回答2:

We were mixing "Response.Redirect" with "return View()" that caused this issue. The browser was redirected, but we tried to still return a view...

BAD CODE

    switch (userType)     {         case "None":             Response.Redirect("http://" + host + "/");             break;         default:             Response.Redirect(internalwebhost + "/exit/");             break;     }      return View(); 

BETTER CODE

    switch (userType)     {         case "None":             url = "http://" + host + "/";             break;         default:             url = internalwebhost + "/exit/";             break;     }      return new RedirectResult(url); 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!