Why does IE11 create blank post request except when Fiddler is running?

ぐ巨炮叔叔 提交于 2019-12-10 10:06:07

问题


My AngularJS $http post requests to my C# WebAPI restful service fail on Windows 8.1 in Internet Explorer 11. Firefox and Chrome both work.

Some more details:

  • The IT department says our network has no proxy
  • All 'automatically detect' and 'use proxy' settings are unchecked in all browsers
  • The requests fail to IIS both on my localhost and running the site and service on a local server
  • Enhanced protection mode of IE11 is off
  • The request's connection header is 'keep-alive' (I tried 'close' too and it still failed)
  • Sometimes one request will succeed and only from the second request will everything fail
  • No error is shown - the request in IE's network tab just says 'Pending' and all headers and body are blank
  • I'm using HTTP, not HTTPS
  • I've tried the meta tag 'X-UA-Compatible' IE9 and Edge
  • The requests fail for colleagues using IE11 on their machines too
  • All calls in all browsers work perfectly when Fiddler is running
  • Visual Studio 2013 browser link is turned off (so the SignalRArtery JS file isn't constantly making calls to the server and interfering with testing)

My AngularJS request call looks like this:

var url = UrlService.GetUrlOfApi() + 'Account/SignIn';
var postData = { 'username' : username, 'password' : password };
$http(
{
    'url': url,
    'data': postData,
    'method': 'POST'
})
.success(function (data)
{
     ...

My C# service looks like this:

[RoutePrefix("Account")]
[AllowAnonymous]
public class AccountController : BaseController
{        
    [ResponseType(typeof(SecureResponseModel))]
    [Route("SignIn")]
    [HttpPost]
    public IHttpActionResult SignIn(HttpRequestMessage request)
    {
        try
        {
            var userSignInDetails = GetPostData<AuthenticationRequestMessage>(request);
            var token = _hisManager.AuthenticateUser(userSignInDetails.Username, userSignInDetails.Password);
            return new SignInResponseMessage(token, ApiErrorCode.success, Request);
        }
        catch(APIException e)
        {
            throw;
        }
    }

This is what a failing call looks like in IE11, totally blank:

This is what a successful calls looks like when Fiddler is running:

Can anyone recommend any other settings to check or things to try please?


回答1:


I have fixed this. My colleague advised the traditional debugging strategy of getting the simplest case to work - so I made a test post controller web service that worked every call:

I then saw the only difference between this method and the one that failed is the BaseController, which contained these methods:

I then changed the code to this to remove the suspicious looking async and await commands:

Everything now works perfectly. But can anyone explain why? In my googling this problem for the past day I've read about IE sending two packets instead of one like other browsers, and about resources being left open interfering with connections. But I don't understand how this await command broke the connection in just one browser.



来源:https://stackoverflow.com/questions/28230563/why-does-ie11-create-blank-post-request-except-when-fiddler-is-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!