Skip to main content


Showing posts from May, 2012

Self Hosting ASP.NET Web API and Understanding the Routing Conventions

In this post, we’ll have a quick look at ASP.NET Web API Self Hosting and Routing Conventions. ASP.NET Web APIs allow you to easily build RESTful applications on top of the .NET framework. ASP.NET Web API is bundled with ASP.NET MVC 4, but you can also self host Web APIs in your custom .NET application (like a console application or a Windows Forms application or in ASP.NET Web Forms applications).Let us quickly build a Pet Store API to query pets using ASP.NET Web API, and we’ll be self hosting the same. Self HostingFire up Visual Studio in Admin mode, and create a new Console application. Then, install the Nuget package AspNetWebApi.SelfHostInstall-Package AspNetWebApi.SelfHostThis will add the required dependencies to your Self host application.class Program { static void Main(string[] args) { //Create a host configuration var selfHostConfiguraiton = new HttpSelfHostConfiguration("http://localhost:8080"); //Setup t…