Sil*_*ght 18 c# asp.net elmah windows-server-2008-r2
我在我的项目中使用elmah - > Elmah.axd来查找错误.
有这样的错误:
System.Web.HttpException: The remote host closed the connection. The error code is 0x800703E3.
Generated: Sun, 27 Nov 2011 13:06:13 GMT
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Web.HttpException (0x800703E3): The remote host closed the connection. The error code is 0x800703E3.
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.HttpWriter.TransmitFile(String filename, Int64 offset, Int64 size, Boolean isImpersonating, Boolean supportsLongTransmitFile)
at System.Web.HttpResponse.TransmitFile(String filename, Int64 offset, Int64 length)
at SalarSoft.Utility.SP1.ResumeDownload.ProcessDownload(String fileName, String headerFileName)
at NiceFileExplorer.en.Download.DownloadFile_SalarSoft(String fileName)
at NiceFileExplorer.en.Download.GoForDownloadFile(String filepath)
at NiceFileExplorer.en.Download.MainCodes()
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
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.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Run Code Online (Sandbox Code Playgroud)
在使用网站时,我们没有看到此错误.
但是elmah多次向我发送此错误.
这个错误意味着什么,我该如何解决?
编辑1
{我的网站是下载移动文件,有时它真的很忙}
{我正在使用Windows Server 2008 r2->远程访问}
编辑2后评论
一些Windows信息和警告(没有错误)今天的日志如下所示:
警告
为应用程序池"ASP.NET 4.0(集成)"提供服务的进程在关闭期间超出了时间限制.进程ID为'6764'.
警告
为应用程序池"ASP.NET 4.0(集成)"提供服务的工作进程"3232"未能在指定的时间内停止协议"http"的侦听器通道.数据字段包含错误编号.
警告
为应用程序池"ASP.NET 4.0(集成)"提供服务的进程在关闭期间超出了时间限制.流程ID为'3928'.
Nei*_*son 32
我在我建立的网站的日志中看到了很多.
AFAIK该异常意味着客户端在页面加载完成之前断开了连接(转到另一个页面/关闭了浏览器).如果客户端正在下载文件,则更有可能出现此错误,因为他们有更多时间决定退出/继续.
用户看不到错误* - 所以我刚刚从Elmah日志中删除了它.
*该网站仅允许经过身份验证的用户.我可以从Elmah身上看到谁经历过错误以及什么时候.我问过的用户,而不是一人曾经报道有在客户端这个bug.
用户取消文件下载时遇到了该错误。在服务器端,它会生成一个带有消息的异常远程主机关闭了连接。错误代码为0x800703E3。但是,异常没有可以单独处理的任何不同类型。
为了更好地在ASP.NET MVC中处理它,我添加了一个异常记录器:
public static class RegisterFilters
{
public static void Execute(HttpConfiguration configuration)
{
configuration.Services.Add(typeof(IExceptionLogger), new WebExceptionLogger());
}
}
Run Code Online (Sandbox Code Playgroud)
和WebExceptionLogger类的实现:
public class WebExceptionLogger : ExceptionLogger
{
private const int RequestCancelledByUserExceptionCode = -2147023901;
public override void Log(ExceptionLoggerContext context)
{
var dependencyScope = context.Request.GetDependencyScope();
var loggerFactory = dependencyScope.GetService(typeof(ILoggerFactory)) as ILoggerFactory;
if (loggerFactory == null)
{
throw new IoCResolutionException<ILoggerFactory>();
}
var logger = loggerFactory.GetTechnicalLogger<WebExceptionLogger>();
if (context.Exception.HResult == RequestCancelledByUserExceptionCode)
{
logger.Info($"Request to url {context.Request.RequestUri} was cancelled by user.");
}
else
{
logger.Error("An unhandled exception has occured", context.Exception);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我注意到此特定错误类型的HResult = -2147023901,因此这就是我的筛选依据。
希望这可以帮助。