Skip navigation
blue data boxes connected by black lines

Microsoft ASP.NET: What's This New Web API?

Don Kiely explains why Microsoft's Web API shines as a new technology for developers

After a respite in 2011 from new product mania, Microsoft is on a tear in 2012 to release early versions for many of its development tools. In the past couple of weeks we've seen a preview for Visual Studio 2011 and ASP.NET MVC 4. We also got our first look at the SQL Server 2012 release candidate. These new releases mark an exciting time for technology, even if it means reevaluating these technologies and determining what skills developers should learn and focus on. For more information on Microsoft's Web API framework, see "Microsoft's Web API Framework: Bridging the Divide Between Web Forms and ASP.NET MVC" and "Microsoft Open Sources ASP.NET MVC, ASP.NET Web API, & ASP.NET Web Pages (Razor) Technologies."

One truly new and exciting technology for Microsoft is the Web API. I wasn't initially enthusiastic about this API, because it seemed to be another web service that's similar to the RESTful API. Do we really need another API when we already have ASP.NET Web Services and Windows Communication Foundation (WCF), or has Microsoft gone nutty about these kinds of APIs just as it has with data-access APIs?

I won't address the last part of that question—Microsoft seems pretty nutty at times—but I'm really starting to warm up to the new Web API, particularly because it's solidified into what appears to be the actual release API. I've come to realize that the reason for this is that the Web API feels natural and seems to fit in with the kinds of applications that I build. The Web API is far more than the relatively basic and hard-to-secure ASP.NET Web Services and the mind-numbingly complex WCF that always feels like a gross overkill for most things a website needs to do. At least this situation is true for the kinds of applications that I build most often these days.

I've outlined some pretty subjective reasons for why I like the new Web API. From an objective and raw technology perspective, the Web API is designed and lives for HTTP. One complex problem with WCF is that it provides everything for everyone for every transport protocol, as Matt Milner explains in his blog post. You have to do some work to use WCF over HTTP. In contrast, the Web API is designed from the ground up to make good use of HTTP, warts and all. The Web API isn't exactly lightweight, but with only one protocol to support the API, it doesn't have a lot of excess baggage.

The other thing that I like about the Web API is that it reflects the direction in which the web is headed. As Scott Guthrie points out in the first part of his blog post series about the Web API, many large websites are exposing Web APIs to make their services available to third-party applications (he cites Facebook, Twitter, LinkedIn, and Netflix as examples). He also lists a bunch of reasons why a Web API is a good solution, including a modern HTTP programming model. It's about time Microsoft got around to providing this model!

I love the close integration of the Web API with ASP.NET MVC. Microsoft chose to implement custom Web APIs by using the well-established controller model. This makes sense because a lot of people were already implementing custom Web APIs by using MVC controllers that return JSON data to the client. That's a slick solution, and the Web API just makes it better. The only big difference is that a Web API controller implements ApiController class instead of Controller class, which in turn implements the IHttpController interface. ApiController is a relatively simple class in the System.Web.Http namespace, so it isn't tied exclusively to ASP.NET MVC, but it understands the HTTP protocol and most of its common verbs.

Best of all, the API is available to a wide variety of clients, including mobile applications. In fact, this fact is probably its biggest selling point. Web applications are increasingly not limited to applications that run in a desktop browser.

I'm not as big a fan of Microsoft's Web API as I am of Entity Framework, but I can already feel the tug. It'll be interesting to see how widely used this new technology becomes when it's finally released, but right now Web API is looking like a winner.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish