Tru*_*Tru 5 internet-explorer xmlhttprequest cors asp.net-web-api angularjs
我有一个访问 .NET WebAPI 服务器端的 AngularJS Web 应用程序。身份验证是通过 AngularJS-OAuth2 库实现的。我在两个不同的端口号下将应用程序和 WebAPI 托管在 localhost 中。我还在服务器端启用了 Microsoft.Owin.Cors 包来处理跨域请求。
在 Chrome 中,GET 和 POST 请求将数据返回到前端。通过检查通过 Fiddler 的流量,我可以看到在请求和响应中发送了一对请求/响应(预检/选项+实际)以及相关的 CORS 标头(包括源和 Access-Control-* 标头)。一切都在预料之中。
但是,在 Internet Explorer 中,我的 GET 请求通过 $http 服务返回数据,但 POST 没有。我可以检查没有预检请求或 CORS 标头(我认为 IE 将不同的端口视为同一来源)。在通过 Fiddler 检查 IE 中的 POST 请求/响应时,我可以观察到它返回 HTTP 状态 200 但状态为中止(设置了 X-ABORTED-WHEN:SendingResponse 标志)。我还可以使用返回的正确数据检查 JSON 响应。
我也试过设置高超时无济于事。$http 调用如下所示:
return $http.post(apiUrl + "/search", service.getParameters(), { timeout: 600000 })
.success(function (data) {...
Run Code Online (Sandbox Code Playgroud)
Fiddler 为 IE POST 请求显示如下内容:
此外(仅)在 IE 中,与此 POST 操作相同的按钮单击也会触发无意的页面刷新。
当正确的数据也返回给客户端并且 Chrome 根本没有任何问题时,为什么 Internet Explorer 只中止 POST 请求?
附加信息
要求:
POST https://localhost:44321/api//search HTTP/1.1
Content-Type: application/json;charset=utf-8
Accept: application/json, text/plain, */*
Authorization: Bearer <token>
Referer: https://localhost:44322/search
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: localhost:44321
Content-Length: 202
DNT: 1
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: .ASPXANONYMOUS=<cookie>
Run Code Online (Sandbox Code Playgroud)
回应:
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: <file>
X-Powered-By: ASP.NET
Date: Wed, 10 Feb 2016 13:43:45 GMT
Content-Length: 2284
Run Code Online (Sandbox Code Playgroud)
Fiddler 会话属性:
SESSION STATE: Aborted.
Request Entity Size: 202 bytes.
Response Entity Size: 2284 bytes.
== FLAGS ==================
BitFlags: [IsHTTPS, ClientPipeReused, ServerPipeReused] 0x19
X-ABORTED-WHEN: SendingResponse
X-CLIENTIP: 127.0.0.1
X-CLIENTPORT: 41889
X-EGRESSPORT: 41890
X-HOSTIP: ::1
X-PROCESSINFO: avp:3584
X-RESPONSEBODYTRANSFERLENGTH: 2,284
X-SERVERSOCKET: REUSE ServerPipe#168
== TIMING INFO ============
ClientConnected: 19:13:42.408
ClientBeginRequest: 19:13:42.444
GotRequestHeaders: 19:13:42.444
ClientDoneRequest: 19:13:42.772
Determine Gateway: 0ms
DNS Lookup: 0ms
TCP/IP Connect: 0ms
HTTPS Handshake: 0ms
ServerConnected: 19:13:42.413
FiddlerBeginRequest: 19:13:42.772
ServerGotRequest: 19:13:42.772
ServerBeginResponse: 19:13:45.360
GotResponseHeaders: 19:13:45.360
ServerDoneResponse: 19:13:45.360
ClientBeginResponse: 19:13:45.360
ClientDoneResponse: 19:13:45.360
Overall Elapsed: 0:00:02.915
The response was buffered before delivery to the client.
== WININET CACHE INFO ============
This URL is not present in the WinINET cache. [Code: 2]
* Note: Data above shows WinINET's current cache state, not the state at the time of the request.
* Note: Data above shows WinINET's Medium Integrity (non-Protected Mode) cache only.
Run Code Online (Sandbox Code Playgroud)
Internet Explorer 支持称为 P3P 的 cookie 限制隐私功能。Web 开发人员经常会被它绊倒,因为没有其他浏览器实现 P3P 标准。
它看起来与那些 QA 类似:
这是一篇博客文章,其中包含如何发送 P3P 信息的示例。这是微软关于P3P配置的文档
| 归档时间: |
|
| 查看次数: |
1984 次 |
| 最近记录: |