Skip to main content

Posts

Showing posts with the label Web API

Self host web API

In this post I will show you how to create web api that run outside IIS application.
Open visual studio and create a console application

Add the Web API and OWIN Packages From the Tools menu, click Library Package Manager, then click Package Manager Console. In the Package Manager Console window, enter the following command:
Install-Package Microsoft.AspNet.WebApi.OwinSelfHost

Right click  the project and add new class named Startup.cs and add following code snippet in it
public class Startup { // This code configures Web API. The Startup class is specified as a type // parameter in the WebApp.Start method. public void Configuration(IAppBuilder appBuilder) { // Configure Web API for self-host. HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", default…