Five Great Reasons to Use the New HttpClient API to Connect to Web Services

Sign in to queue

Description

The new Windows.Web.Http.HttpClient family of classes lets you connect to web services easily and with lots of control. In this talk you’ll learn about these new classes, how and when to use them, how to connect to popular web services, and how to control your caches and cookies. You'll also learn new ways to speed up your app start-up by prudently pre-stocking your HTTP cache with data you know your users will want.
For more information, check out this course on Microsoft Virtual Academy:

Day:

3

Level:

400

Session Type:

Breakout

Code:

4-092

Room:

South Hall: Gateway Ballroom 102

Embed

Download

Download this episode

For more information, check out this course on Microsoft Virtual Academy:

The Discussion

  • User profile image
    jans

    where can I find windows.web.http (framework 4.5.1) namespace/library installed and later reference? Thanks

  • User profile image
    jans

    and you just mentioned having that namespace available in MSDN. I was looking for it and never found... could you provide the link?

  • User profile image
    PhrostByte

    jans: The new home of HttpClient is NuGet package Microsoft.Net.Http.

  • User profile image
    WeCarpoolCOM

    while selecting speakers for talks MS need to test their voices @ 2x speed. Some are just impossible to listen to @ 1.4x or @2x speeds like this speaker

  • User profile image
    PeSmith

    Jans -- there are three HttpClient APIs in Windows.  This talk is all about the new 81. Window.Web.Http HttpClient; it's a WinRT component that works with C++, C#, VB and for JavaScript 'WWA' app store apps.  (It also works for desktop apps).

     

    There's also the .NET HttpClient that was introduced with 4.5, plus a Portable Class Library (PCL) HttpClient that just reached (IIRC) version 2.1 and which works with .NET 4.0.  But those are different.

     

     

  • User profile image
    WeCarpoolCOM

    can a filter be used to assign unique IP address to each instance of httpclient?

  • User profile image
    PeSmith

    @WeCarpoolCOM: We don't give you quick that much power!  What scenario do you have that you need to assign IP addresses like this?

  • User profile image
    Lew_S

    @PeSmith Where can we get that poster you provided at the talk?

  • User profile image
    clamont2

    3 questions: Can I do custom validation of the SSL certificate?  

    Can I do custom validation of the SSL connection?  I want to be aware of BEAST, CRIME, and other vulnerabilities my client is open to.  (see security.stackexchange.com ).  Related questions: Am I using TLS 1.0 or 1.1?  What cipher and encryption is the connection using?

    Can I check the "issued by" parameter of each SSL certificate?  I want to determine if an in-line SSL proxy filter is inspecting my traffic (Bluecoat corporate proxy)

    How many concurrent connections are allowed to the same fqdn?  Traditionally, in IE and javascript I am limited to the number of concurrent HTTP calls I can have to a given domain.  How is this limitation applied to C# and the other platforms?

  • User profile image
    Network​Developer​Experience

    The forums at https://social.msdn.microsoft.com/Forums/windowsapps/en-US/home?category=windowsapps81preview are a great place to ask questions like these -- the moderators are very active at answering questions.

    Yes, you get some information about the SSL connection.  In particular the HttpRequestMessage has a TranportInformation property that includes the SSL certificate.  For validation, I'd recommend creating a simple filter that, on getting a response, checks the responses' httpRequest message for the transport information.  If you decide that the SSL isn't good enough, you can then just kill the response entirely.  By placing the check in a filter, you can have a good check without having to clutter up the rest of your app logic.

    The TransportInformation ServerCertificate is an ordinary Windows.Security.Cryptography.Certificates.Certifcate object.  That object includes an Issuer.

    You can control the number of connection with the HttpBaseProtocolFilter "MaxConnectionsPerServer" value.

     

  • User profile image
    Network​Developer​Experience

    We passed out a nifty poster at this session (and then later at one of the booths in the Big Room).  An enhanced version of that poster is now on the Download Center; check it out at https://download.microsoft.com/download/0/2/8/02809141-3329-4412-8AC4-AA41B406055C/WinRT81%20HttpClient%20Poster.pdf

    The poster prints out at 11x17 ("tabloid") size.  The poster includes the various classes that make up the HttpClient family of classes and how they interrelate and includes 5 small code samples that demonstrate using the classes.

     

Add Your 2 Cents