0
votes

I'm trying to use WebRequestHandler with HttpClient in an ASP.NET MVC controller with .NET 4.0. I've got the latest HttpClient installed from NuGet.

When passing a WebRequestHandler to HttpClient, requests never complete. Looking via a debugging proxy, responses from the server just get cut off at some point through the response body. Doesn't seem to be a pattern as to where it cuts off.

Here's a test case:

public class HomeController : Controller
{
    public async Task<ActionResult> Index()
    {
        var handler = new WebRequestHandler();
        var httpClient = new HttpClient(handler);
        var google = await httpClient.GetStringAsync("http://www.google.com");
        return View(google);
    }
}

It works fine if I replace WebRequestHandler with HttpClientHandler, but I need to add a client certificate.

I've tried changing various settings of WebRequestHandler, but to no avail. Any ideas?

1

1 Answers

0
votes

Well, this just seems to be a bug and regression in HttpClient.

I went back to v2.0.20710.0 and it works fine.