Feedback on ASP.NET Web API

Allow for non-asynchronous calls to the Web API

It looks like the synchronous code was removed or not ported from WCF Web API to the new ASP.NET Web API. It would be nice to have that back while we're still on .NET 4 without the 4.5 async features. My code went from 5 lines to 16, just to make a request and get a response.

22 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    skippyfireskippyfire shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    5 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • tugberktugberk commented  ·   ·  Flag as inappropriate

        @skippyfire it has go-live license, my friend. I am not a lawyer but it means official support.

        Best way of making both sides happy here is to provide extensions library for sync methods. I cannot stand to see `GetSync` method.

        BTW, see this blog post: http://www.tugberkugurlu.com/archive/my-take-on-task-base-asynchronous-programming-in-c-sharp-5-0-and-asp-net-mvc-web-applications

        There is a benchmark there composed by a load test. Take a look at the result and see how evil sync methods are for a website which gets lots of traffic and deals with long running I/O operations.

      • skippyfireskippyfire commented  ·   ·  Flag as inappropriate

        @Piers Yeah, I did get a way of doing this, but it's a little roundabout. I think it would be nice to have a GetSync version of the method, at least for now while the async code is still ugly.

        @tugberk I don't consider a CTP to be "support".

      • tugberktugberk commented  ·   ·  Flag as inappropriate

        this's an awful idea. Please do not make this happen!

        If you are on .NET 4.0, you already have the async support. Just go and get the Visual Studio Async CTP.

        If you must support this, please do not do this out of the box. Make a new extensions library (HttpClientSync maybe) and provide extensions. I do not wanna see the sync versions of those methods.

      • Daniel RothAdminDaniel Roth (Admin, ASP.NET Future Feature Feedback) commented  ·   ·  Flag as inappropriate

        There are cases where .Result and .Wait() can be dangerous, so we are considering making safe synchronous versions of the HttpClient APIs available. In general, blocking the thread is a bad thing, but writting correct async code on .NET 4 is still very difficult. Vote this one up if you think this is important.

      Feedback and Knowledge Base