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
http://www.asp.net/aspnet/overview/owin-and-katana/getting-started-with-owin-and-katana
http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api
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:
Below is the code for the Startup.cs file:
http://www.asp.net/aspnet/overview/owin-and-katana/getting-started-with-owin-and-katana
http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api
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:
- Create an Empty ASP.NET Web Application
- Add a NuGet package for Microsoft.Owin.Host.SystemWeb and Microsoft ASP.NET Web API 2.2 OWIN
- Add an OWIN Startup Class to your project
- 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.
- Add any references to Web API Class Libraries.
- 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
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
app.UseWebApi(config);
}
}
}
No comments:
Post a Comment