Tuesday, January 13, 2015

Setting up Project Katana to host ASP.NET Web API in IIS

If you have been reading about Project Katana, you have probably come across these articles: http://www.asp.net/aspnet/overview/owin-and-katana/an-overview-of-project-katana



However, the problem with all of these articles is that it demonstrates how Katana can be used to Self Host ASP.NET Web API in a Console Application but provides very little information on how Katana can be used to provide standard OWIN pipeline hosting of ASP.NET Web API in IIS!!

Well, here is some clarification on how to set up a Katana Web Application:

  1. Create an Empty ASP.NET Web Application
  2. Add a NuGet package for Microsoft.Owin.Host.SystemWeb and Microsoft ASP.NET Web API 2.2 OWIN
  3. Add an OWIN Startup Class to your project
  4. Add the necessary code to the Configuration method of the Startup class.  This code will basically be a duplicate of the WebApiConfig.cs file that are normally found in ASP.NET Web API projects with the addition of the Katana specific project code.
  5. Add any references to Web API Class Libraries.
  6. Run your Katana Web Application Host and verify that you can access the required Web API Urls.

Below is the code for the Startup.cs file:

using System;

using System.Threading.Tasks;

using Microsoft.Owin;

using Owin;

using System.Web.Http;


[assembly: OwinStartup(typeof(KatanaHost.Startup))]


namespace KatanaHost


    public class Startup


        public void Configuration(IAppBuilder app)


            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888

            var config = new HttpConfiguration();


            // Web API routes




                name: "DefaultApi",

                routeTemplate: "api/{controller}/{id}",

                defaults: new { id = RouteParameter.Optional }







No comments:

Post a Comment