如何赶在IHttpHandler的特定HttpException(#0x80072746) [英] How to catch a specific HttpException (#0x80072746) in an IHttpHandler

查看:289
本文介绍了如何赶在IHttpHandler的特定HttpException(#0x80072746)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来,这HttpException(0x80072746 - 远程主机关闭了连接),举个例子,虽然我们在传输文件的用户关闭窗口皆可抛。即使我们在更小的块发送的文件,并检查客户端仍连接,仍然会出现异常。我们希望能够赶上这个特定的异常,忽略它。

It appears that this HttpException (0x80072746 - The remote host closed the connection) can be thrown if, for example, the user closes the window whilst we are transmitting a file. Even if we send the files in smaller blocks and check the client is still connected, the exception can still occur. We want to be able to catch this specific exception, to ignore it.

在HttpException提供的错误码是一个Int32 - 太小,不能容纳0x80072746,那么,我们发现这个号码

The ErrorCode provided in the HttpException is an Int32 - too small to hold 0x80072746, so where do we find this number?

推荐答案

该HttpException.ErrorCode属性为您提供您正在寻找的错误代码。使它看起来类似于这样:

The HttpException.ErrorCode property gives you the error code you are looking for. Make it look similar to this:

        try {
            //...
        }
        catch (HttpException ex) {
            if ((uint)ex.ErrorCode != 0x80072746) throw;
        }

这篇关于如何赶在IHttpHandler的特定HttpException(#0x80072746)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆