ASP.NET Web API Released and a Preview of What’s Next

Today we announced the release of Visual Studio 2012 and .NET 4.5 which of course includes ASP.NET Web API. There is a ton of new features in VS 2012 and I highly recommend checking out the videos by Scott Hanselman demonstrating a broad set of features of VS 2012 and .NET 4.5.

In addition to shipping as part of Visual Studio 2012 you can also download Web API for Visual Studio 2010 as a standalone installer and as always, you can find us in our Open Source home on codeplex where you can see the source, contribute pull requests, and log issues. The official release (RTM) corresponds to this branch in the source repository.

Further, you can find a bunch of ASP.NET Web API and HttpClient samples demonstrating many of the features. The samples also live on codeplex so that you can download them and work with them. Here you will find samples for both VS 2010 and VS 2012 illustrating a variety of features of both ASP.NET Web API and HttpClient.

In addition to all this we also today release four preview NuGet packages which build on the ASP.NET Web API RTM bits but provide new features. The previews are explicitly marked as alpha releases as they are early builds. The previews are continuously updated and you can get the latest builds from our nightly NuGet feed, please see Using Nightly ASP.NET Web Stack NuGet Packages for details.


The Microsoft ASP.NET Web API OData package contains everything you need to create OData endpoints using ASP.NET Web API and to support OData query syntax for your Web APIs. It supersedes the early query support in ASP.NET Web API Beta with much better support for both querying as well as sending and receiving OData formatted payloads. For a detailed description of the OData support, please see the blog OData support in ASP.NET Web API.

There are two samples demonstrating how to use the OData package that both available in source as part of ASP.NET Web API and HttpClient samples:


This sample shows how to introduce OData queries in ASP.NET Web API using either the [Queryable] attribute or by using the ODataQueryOptions action parameter which allows the action to manually inspect the query before it is being executed. The sample illustrates queries using $orderby, $skip, $top, and $filter as well as any() and all().


This sample illustrates how to create an OData service consisting of four entities and three ApiControllers. The controllers provide various levels of functionality in terms of the OData functionality they expose. In addition the OData service exposes a $metadata document which allows the data to the consumed by WCF Data Service clients and other clients that accept the $metadata format.

The data model contains three entities (Supplier, ProductFamily, and Product) connected in various ways and uses three sample controllers demonstrating various levels of exposing OData ranging from Query to Update and Delete.

Furthermore, the ODataService exposes a Service Document (aka. $metadata document) that lists all the top-level entities so clients can discover them. This enables OData clients to discover and consume OData Services exposed through ASP.NET Web API.

Help Page

The Microsoft ASP.NET Web API Help Page package automatically generates help page content for Web APIs on your site. Visitors to your help page can use this content to learn how to call your web APIs. Everything generated by the help page is fully customizable using ASP.NET MVC and Razor. ASP.NET Web API Help Page is a great addition to any ASP.NET Web API project.

For more information and a nice video walkthrough, please see the blog Introducing the ASP.NET Web API Help Page (Preview) 


The Microsoft ASP.NET Web API Tracing package allows the ASP.NET Web API framework to trace to System.Diagnostics.Trace so that you can now get trace messages from the entire ASP.NET Web API message pipeline from when a request starts being processed to a response is generated.

When installing this package in your project, it adds the following source file was added to your project:

  • App_Start\TraceConfig.cs

To enable tracing in your application, simply add the following line of code to your startup code (for example in WebApiConfig.cs or Global.asax.cs in an MVC 4 project):

  • TraceConfig.Register(config);

where ‘config’ is the HttpConfiguration instance for your application. When running your application you can now see trace output written toSystem.Diagnostics.Trace.

For more information about tracing, please see the blog ASP.NET Web API Tracing (Preview)

System.Net.Http.Formatting for Windows 8

The Microsoft ASP.NET Web API Client Libraries package adds support for formatting and content negotiation to System.Net.Http when writing Windows Store Apps. It includes support for JSON, XML, form URL encoded data, as well as MIME multipart. This package requires Visual Studio 2012 and Windows 8.

We are looking forward to your feedback – both on RTM as well as these previews.

Have fun!


Comments (22)

  1. Chris Marisic says:

    How does a package "requires Visual Studio 2012 and Windows 8."?

  2. Wallace Turner says:

    1) The link to the git repo is broken (404)

    2) What version of the source code corresponds to the RTM? eg the assembly product version is 4.0.20710.0 – however what commit does this correspond to? It would be better to embed the commit Id (eg 012d90328619) into the assembly so this is obvious.

  3. Chris, you can only build Windows Store Apps using Visual Studio 2012.

  4. Wallace Turner says:

    Thanks Henrik, so last change in RTM was Jul 28 (012d90328619) ?

    Trying to determine the changes between RC and RTM…

  5. Wallace, yup, that's right

  6. Daniel Roth says:

    You can find a list of the changes between RC and RTM in the RTM release notes:…/mvc4-release-notes

  7. Daniel Roth says:

    The System.Net.Http.Formatting support for Windows 8 is actually included in an update version of the ASP.NET Web API Client package which also includes the standard .NET 4 support that is shipping with ASP.NET Web API.

  8. Kakone says:

    I tried to install the package Microsoft.AspNet.WebApi.OData -Pre, but there is a problem with the System.Spatial dependency :

    PM> Install-Package Microsoft.AspNet.WebApi.OData -Pre

    Tentative de résolution de la dépendance « Microsoft.Data.Edm (= 5.0.1) ».

    Tentative de résolution de la dépendance « Microsoft.Data.OData (= 5.0.1) ».

    Tentative de résolution de la dépendance « System.Spatial (≥ 5.0.1) ».

    Tentative de résolution de la dépendance « Microsoft.Net.Http (≥ 2.0.20710.0 && < 2.1) ».

    Tentative de résolution de la dépendance « System.Spatial (= 5.0.1) ».

    Install-Package : Référence déjà une nouvelle version de « System.Spatial ».

    Au niveau de ligne : 1 Caractère : 16

    + Install-Package <<<<  Microsoft.AspNet.WebApi.OData -Pre

       + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException

       + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

  9. Jaume Sancho says:

    Having the same issue as Kakone on Visual Studio 2012 RC

    I have also tried uninstalling System.Spatial 5.1.0-rc1 and installed specifically the System.Spatial 5.0.1 dependency.

    But Nuget still complains about a "more recent version".

    Now I'm installing 2012 RTM, will report if that helps at all.



  10. Chris Marisic says:

    @Henrik so it's not really that the package requires win8 it's that the package's only purpose is for Win8 app store development?

  11. RaghuRam says:

    @Kakone, @Jaume The webapi team knows this odata package issue and is working on a fix for the package. There has been a 5.0.2-rc release of System.Spatial just after our packages were released which broke our dependency chain.

  12. @RaghuRam thanks for the heads up!

    I've finally gotten my project to a working state by reverting all changes.

    I'll stay tuned for an update on this.


  13. @Henrik I can't find QueryableAttribute in v4.0.20710.0 of System.Web.Http. Was it moved somewhere?

  14. I0da, the QueryableAttribute is now part of the new OData package described above.


  15. Cody says:

    Was the ResultLimit Feature of [Queryable] also removed?

    It doesn't seem to be a part of [Queryable] anymore. In RC version it had this usage: [Queryable(ResultLimit = 10)]

    Is there now a new way to limit the amount of data that is returned?


  16. Cody, The sample ODataQueryableSample (see [1] and [2]) shows how to manually restrict the query. It's quite frankly a bit clunky at the moment — we'll be improving the experience…




  17. Upgrading to RTM says:

    Hi Henrik,

    We just upgraded our API implementation to the RTM of WebAPI yesterday – totally painless – so definitely pleased about that!  Also excited about where the OData team is going and love the Tracing support – we have been blogging about experiences building an API using WebAPI as we go –

    What are the plans for WebAPI itself (rather then the supporting libraries) from here on, will there be an out-of-band WebAPI 4.5 release next?

  18. Glad you had an easy upgrade! We are still in the process of finding out the plans moving forward so I can't say anything definite yet. Once we know more about exactly what and when then we will certainly make it available. Looking forward to your feedback and suggestions!

  19. BenHayat says:


    Two questions but kind of related:

    a) When will be getting info on the continuation of SPA development and info on the Upshot?

    b) Will SPA and Web API SP1 be timed together as the next "Web Stack" update?

    Thank you in advance!


  20. whirlston food processing machinery says:

    This is a really nice post. Glad to be here and see this. Thank you very much for sharing.

    <a href=" ">whirlston food processing machinery</a>

  21. FFFFF says:

    Please update the links in this post, there are many that are invalid