At some point soon lots of people are going to start writing these epic blog posts about Visual Studio 2012. They will include LOTS of screenshots (some good and some bad), some small code samples and minimal context. I can't speak for other teams; I can only talk about what we worked on. The <AngleBrackets/> folks in Azure Platform and Tools (ASP.NET, IIS, WCF, EF, Azure much and more) have been putting a lot of work into what I sometimes call "Death by a Thousand Tiny Cuts." It's the little irritants that are as frustrating (or more so) as the big missing features.

Rather than a giant super post (although I'll do that at some point) I thought I'd showcase some Tiny Happy Features that the team worked on just because it made life better. Some are large some are small, but all are tiny happy features.

There's Enterprise Web Services that use SOAP and WS-*.* and they are great for many transactional or complex scenarios. Then there are lighter weight RESTful web services or "Web APIs" that use JSON, XML and respect all of the goodness and stability that is the HTTP specification.

WCF is alive and well and ASP.NET is alive and well and there are reasons to use each technology. As this article says very well, "The world of SOAP and the world of HTTP services are very different. SOAP allows us to place all the knowledge required by our service in the message itself" vs. "you can use [Web APIs] to create HTTP services that only use the standard HTTP concepts (URIs and verbs), and to to create services that use more advanced HTTP features – request/response headers, hypermedia concepts etc."

Rick Strahl says that ASP.NET Web API is different than other frameworks because "it was built from the ground up around the HTTP protocol and its messaging semantics. Unlike WCF REST or ASP.NET AJAX with ASMX, it’s a brand new platform rather than bolted on technology that is supposed to work in the context of an existing framework. The strength of the new ASP.NET Web API is that it combines the best features of the platforms that came before it, to provide a comprehensive and very usable HTTP platform."

Content Negotiation based on Accept headers for request and response serialization

Support for a host of supported output formats including JSON, XML, ATOM

Strong default support for REST semantics but they are optional

Easily extensible Formatter support to add new input/output types

Deep support for more advanced HTTP features via HttpResponseMessage and HttpRequestMessage classes and strongly typed Enums to describe many HTTP operations

Convention based design that drives you into doing the right thing for HTTP Services

Very extensible, based on MVC like extensibility model of Formatters and Filters

Self-hostable in non-Web applications

Testable using testing concepts similar to MVC

ASP.NET Web API

There's some lovely new samples at this Git Repository. Just "git clone https://git01.codeplex.com/aspnet" or download the zip. You can also familiarize yourself with ASP.NET and the Web API at the new http://www.asp.net/webapi site.

By the way, I'll be publishing a bunch (13!) of new videos showcasing Web API plus a lot of other Tiny Happy Features next week on the 15th. Each video will only be 5 minutes long and will be a great way to get up to speed on all the new tech over lunch.

Here's one nice little sample that will perhaps cause you to rethink what you can accomplish with ASP.NET web technologies. It's a console application that hosts ASP.NET Web API. To be clear, there's no IIS involved.

That code sets up a route, starts the self-hosting process, and waits. Here's a controller at http://localhost:50231/Contact that will ECHO whatever contact you HTTP POST to it as content-type JSON. Note that Contact is a C# type as a parameter to Post().

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

Its great Microsoft made this framework just as pluggable as ASP.NET MVC. For example, it is even possible to add versioning to ASP.NET web API without much effort: http://damsteen.nl/blog/implementing-versioning-in-asp.net-web-api

Dev

Saturday, August 11, 2012 9:48:06 AM UTC

Dude, completely OT, but I have to say it. I ROFL when I saw Nandor Tanczos as your 'REST' guy; funny how he turns up in a generic Rasti Guy search (http://www.parliament.nz/en-NZ/MPP/MPs/Former/4/6/a/48PlibMPsFormerNandorTanczos1-Tanczos-Nandor.htm)

Hi, just to say I have created a little utility : http://httpsysmanager.codeplex.com/ to facilitate http.sys configuration part :)Here are some internal details on http://www.codeproject.com/Articles/437733/Demystify-http-sys-with-HttpSysManager

As a lone dev, I can't afford to spend all that time mastering WCF intricacies: customers don't really like to be invoiced for time spent on infrastructure details, they'd rather pay for their business problems getting solved, so I'm glad that people like Glenn Block looked into simplifying the common use cases of WCF and produce something with a sane default behaviour that will be extremely useful for building APIs.I also love the fact that it can easily be self-hosted, not every problem needs the headache of administering a full-blown web server.

We just completed the first version of our API using Web API - I took the time to document the process we went through here in a series of 9 posts:

http://bit.ly/etwebapi

Returning JToken's or dynamic works really well, also you using nested IDictionary<string,object> instances or performing JToken rewriting in your MediaTypeFormatter works well too for piggy-backing dynamic content into your static view models - and allows you stick with static typing for the most part within your API controller implementation.

What is the best way for putting in a request for XML parsers to support "dynamic" on the radar? Connect? From a WEBAPI perspective the promise of content negotiation falls short for PATCH requests wherein you are looking to accept a set of key value pairs typed as "dynamic" instead of a full blown DTO.

Abhijeet Patel

Monday, June 10, 2013 3:39:27 PM UTC

Scott,

It is nice to see Asp.NET Web Api as new feature. But I don't understand why the Web Api is part of Asp.NTE MVC project. Off course it is known that it uses MVC controller. But this doesn't mean it should be part of MVC. Here is a simple scenario. I want to provide simple REST service using Web APi. Mind you no MVC UI required and no Model it required. The POCO come as independent project(Library or services). And the only piece I'll use going to be Controller. Model and View will be deleted. I don't want to keep them there, because they are not relevant to my project. Mind you I'm going to provide RESTful service.

So to provide RESTful service why on earth I do need to create MVC project. Don't understand the relevance and why it is added as part of MVC project

Regards

Master man

Monday, July 08, 2013 8:09:44 AM UTC

Master man,You can use the MVC ui functionality on your Web API to send rendered content instead of just serialized objects, so I think it is appropriate to retain that functionality built in.

As an aside I wish SignalR would have a similarly tighter binding with MVC so as to make it easier to have it push dynamic rendered content in the MVC model.