2014-02-28 390 views
0

我在我的应用程序中收到此错误。我在错误日志中经常看到这些错误,但我不确定源代码。 以下是错误的堆栈跟踪。异常(消息):远程主机关闭了连接。错误代码是0x800703E3

Exception (Stack): 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.Mvc.FileContentResult.WriteFile(HttpResponseBase response)  
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()  
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)  
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)  
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) 

但做了一些谷歌上搜索我发现,原因可能是我下载文件的方式,但我不知道之后。这里也是源代码。

string Id = id.Split(new[] { '!' }).First(); 
DocumentInfo Content = Doc.ContentDownLoad(Settings, docId); 
Response.Clear(); 
Response.BufferOutput = false; 
fileName = Content.DocName + "." + Content.FileExtn; 
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName); 

return File(Content.Content, Content.MimeType); 

我在这里尝试了一些建议的解决方案,但没有任何工作。有人可以提出一个可行的解我在这里做错了什么?

+0

你能详细说明你试过的吗? – Tommy

+0

我之前和之后使用的视图开始使用FileResult,然后我尝试使用Response.Flush()但静静地获取错误 – Sri

+0

这是一个公共服务器? –

回答

0

此异常表示用户在关闭浏览器或导航到其他页面之前关闭了连接。用户永远不会看到这个错误,但Elmah记录它。你可以检查你的客户端在写入下游之前是否已连接,但它不能完全解决问题。

if (Response.IsClientConnected) 
{ 
    // write your file to down stream 
} 

我建议你使用Elmah的过滤器来防止Elmah记录它。 elmah Error Filtering

相关问题