我在我的网站上的onclick事件处理程序中执行了以下JavaScript代码 .

var newRequest = new window.XMLHttpRequest();
newRequest.open('POST', '/index.cfm', true);    
newRequest.send('q');

如果我使用IE 11并打开位于测试服务器上的网页,我可以看到请求按照预期使用内容长度为1的Fiddler和发布数据中的“q”发送 . 但是,如果我打开我的应用程序来托管WebBrowser控件并导航到我的测试服务器上的同一个网站并让它执行上面的代码我总是可以看到请求正在进行,但Content-Length标头是0并且'q'不随请求一起发送 . 这是Fiddler中出现的失败请求 .

POST http://test.mycompany.com/index.cfm HTTP/1.1
Accept: */*
Referer: http://test.mycompany.com/Curtis/BrowserTests/BrowserEventTests.html
Accept-Language: en-US
Content-Type: text/plain;charset=UTF-8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: test.mycompany.com
Content-Length: 0
Connection: Keep-Alive
Pragma: no-cache

如果我然后将我的可执行文件的HKEY_CURRENT_USER \ Software \ Microsoft \ Internet Explorer \ Main \ FeatureControl \ FEATURE_BROWSER_EMULATION注册表值设置为9000,那么它可以工作并按预期发送发布数据 .

以下是Fiddler报告的正确请求 .

POST http://test.mycompany.com/index.cfm HTTP/1.1
Accept: */*
Referer: http://test.mycompany.com/Curtis/BrowserTests/BrowserEventTests.html
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: test.mycompany.com
Content-Length: 1
Connection: Keep-Alive
Pragma: no-cache

q

如果我将该值更改回10000或11000,则它不起作用 . 有没有人对使用WebBrowser控件无法正确发送帖子数据的原因有任何想法?我已将IE设置重置为出厂默认设置,但行为没有变化 .

Update: 如果我改变JavaScript看起来像这样,那么它适用于设置为10000的仿真模式 .

var newRequest = new ActiveXObject("Msxml2.XMLHTTP");
newRequest.open('POST', '/index.cfm', true);
newRequest.send('q');

这只是一个需要报告的错误吗?