【问题标题】:IE9 XmlHttpRequest returns 12019 error instead of HTTP/417 response codeIE9 XmlHttpRequest 返回 12019 错误而不是 HTTP/417 响应代码
【发布时间】:2013-07-11 12:48:09
【问题描述】:

我在客户端对 WCF 服务的 ajax 请求进行了一些错误处理,

 self.remove = function (dep, processingResult) {
            var data = { "id": dep };
            $.ajax({
                url: 'my.svc/remove',
                type: 'POST',
                contentType: 'application/json',
                dataType: "json",
                cache: false,
                data: JSON.stringify(data),
                complete: function (e, xhr, settings) {
                    var message = self.getMessage(e.status);                
                    switch (e.status) {
                        case 200:
                            processingResult();
                            break;                  
                        case 417:
                            console.log(e.statusText);
                            radalert(message + e.statusText, null, null, "417");
                            break;
                        default:
                            {
                                console.log(e.statusText);
                                radalert(message, null, null, "bekey");
                            }
                    }
                }
            });
        };

在某些情况下,我返回错误 417,但 IE9 得到的结果却是一些 12019 错误。 包括 IE10 在内的所有其他浏览器都获得了正确的值。

为什么会发生以及如何解决?

12019 - ERROR_INTERNET_INCORRECT_HANDLE_STATE 请求的操作无法执行,因为 提供的句柄状态不正确。

看起来返回此代码不是很好的做法。我说的对吗?

  WebOperationContext ctx;
//....
  ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.ExpectationFailed;//417
//...

【问题讨论】:

标签: jquery asp.net wcf internet-explorer


【解决方案1】:

如果清除缓存没有帮助,这可能与 URLMon 如何包装某些 HTTP 错误状态代码有关;例如 IE9 及以下版本会将 HTTP/204 响应转换为伪造的 1223 状态代码(请参阅http://www.enhanceie.com/ie/bugs.asp

这个问题在 IE10 中得到了修复,使得服务器的响应状态可以正确的返回给脚本。

【讨论】:

    猜你喜欢
    • 2018-09-15
    • 1970-01-01
    • 2012-03-09
    • 1970-01-01
    • 2014-09-03
    • 1970-01-01
    • 1970-01-01
    • 2016-02-20
    • 2014-03-14
    相关资源
    最近更新 更多