如何在 IHttpHandler 中捕获特定的 HttpException (#0x80072746)
例如,如果用户在我们传输文件时关闭窗口,则似乎可以抛出此 HttpException(0x80072746 - 远程主机关闭连接)。即使我们以较小的块发送文件并检查客户端是否仍然连接,异常仍然可能发生。我们希望能够捕获这个特定的异常,并忽略它。
HttpException 中提供的 ErrorCode 是一个 Int32 - 太小,无法容纳 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.
The ErrorCode provided in the HttpException is an Int32 - too small to hold 0x80072746, so where do we find this number?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Int32 并不是真的太小而无法容纳 0x80072746;仅在“正常”表示法中,该数字为负数:0x80072746 == -2147014842,您可以创建一个常量来比较错误代码:
或
Int32 is not really too small to hold 0x80072746; only in “normal” notation, this number is negative: 0x80072746 == -2147014842, you can create a constant to compare the error code against:
or
HttpException.ErrorCode 属性为您提供您正在查找的错误代码。让它看起来类似于这样:
The HttpException.ErrorCode property gives you the error code you are looking for. Make it look similar to this:
在计算机科学中,负整数以十六进制表示,第一位设置为 1(来源:wikipediat )。
据此,十六进制数
0x80072746
可以用基数 2 编写:第一个位被设置...然后它实际上对应于这个数字:
最终可以用基数 10 表示,如下所示:
这最终实际上是一个正确的整数。
不知道是否可以帮助您解决问题。
In computer science, a negative integer is represented in hexadecimal with a the first bit set to 1 (source: wikipediat).
According that, the hexadecimal number
0x80072746
can be written in base 2 :The first bit is set... then it correspond actually to this number :
which can finally be represented in base 10 like this :
which is finally, actually an correct integer.
Don't know if it can help you to solve the problem.