Creating a self-hosted OData Web API service

Some time ago Microsoft has introduced the ASP.NET Web API framework. It’s a framework you can use to create your own RESTful services . It’s much like WCF Data Services or WCF RIA Services , but a lot easier to use (IMO). I’ve never liked the WCF-stack much, probably because configuring it always posed to be a hassle.

Using the Web API framework is much easier and you have to configure a lot less, or at least I haven’t found all of the configurable options yet. Then again, it’s created for entirely different purposes of course.

To create a service you select the ASP.NET MVC4 project template and can create new controllers which inherit from the ApiController . It’s also possible to do some awesome queries on your client nowadays, because Web API is capable of supporting OData ! Install the latest stable NuGet package and you are ready to go!

Because I was put on a new project, I was finally able to do some real work with ASP.NET Web API. We had to develop a solution containing a so called self-hosted Web API service which also supported OData queries. This sounds like a lot of work, but it’s actually rather easy to do so nowadays.

Read more →