Sponsor: Do you build complex software systems? See how NServiceBus makes it easier to design, build, and manage software systems that use message queues to achieve loose coupling. Get started for free.
It is possible to migrate from Katana (Microsoft’s OWIN implementation) to ASP.NET Core. The secret is in still using the full .NET Framework.Full Framework?
I recently spoke at the Windsor-Essex .NET Developers group and was explaining to some developers that ASP.NET Core could run on the full .NET Framework. The reaction I got was slight confusion. Based on this, I assume there are others that were unaware of this. The other issue is the term “Full Framework”. I’m not sure if this is the common term, but I have heard it from many as reference to the .NET Framework that comes shipped with Windows. This is the framework most are using today.Why?
The reason you may want to use ASP.NET Core with Full Framework is because you are already using an Owin implementation like Katana. I’ve previously blogged about how you can use Katana to Self Host ASP.NET Web API as well as NancyFX ASP.NET Core supports Owin Middleware. Which means you could migrate your Katana Self Host to use ASP.NET Core with Kestrel.File > New Project
If you haven’t already, you need to install the .NET Core SDK for Visual Studio. As of this post, 2016-07-06, Visual Studio 2015 Update 3 has the latest bits. When you create a new project in Visual Studio, you have the option of created a ASP.NET Core app, but using .NET Full Framework. In this example I’m going to create a empty web application. The next step is to install the Microsoft.AspNetCore.Owin package from Nuget. This will enable use to Owin Middleware from ASP.NET Core’s IApplicationBuilder.Install-Package Microsoft.AspNetCore.Owin
Nancy
As you may have already seen on my blog, I’m a fan of Nancy and have been using it with Katana for awhile now. In order to use Nancy with ASP.NET Core, we can install the same packages we needed when using it with Katana.Install-Package Nancy Install-Package Nancy.OwinNow in our Startup.cs we can add Owin to our pipeline which then can call Nancy.
Very interesting idea. Would that give any performance improvements?
I would assume the actual accepting of the request would be since it’s using kestrel vs httplistener. After it goes through kestrel and gets into your middleware, all would be the same at that point.
So I am assuming you just would need to add dependencies for the full framework? Because I’ve been struggling to try using Nancy/Katana/anything to develop some basic proof-of-concept microservices with .NET Core, and keep getting NuGet dependency errors… so maybe this would resolve that issue?? I would hope so.
I’ve communicated this (NuGet dependency errors with Nancy and .NET Core) to the Nancy team and they said they aren’t yet there for support but I *could* compile the nightly and get it working, which I’ve done, but for trying to use on an upcoming big project I’d rather stick with something not based on nightly builds *just yet*
This week I believe that the Nancy team released the Nancy 2.0 beta to NuGet, so you should now be able to use .NET Core instead of full framework. There are some breaking changes related to defining the routes in 2.0 however.
If you wanted to stick to Nancy 1.x, you would have to continue to use full framework on top of ASP.NET Core and using the OWIN middleware.
Thank you for this post Derek; we have a self-hosted ASP.NET Web API written on Owin and Katana. It seems that migrating it to ASP.NET Core would afford future opportunities and perhaps some performance benefits. I am curious though what the advantage of using ASP.NET Core while targeting the .Net full framework affords? Is the thought being that it could be used for incremental development in working towards a .Net Core implementation? Also It seems that Katana is moving towards .Net Core (https://goo.gl/vZ3jOW) — does this make the exercise moot? Is it now possible to migrate to ASP.Net Core’s .Net Core framework if we want? Still trying to conceptualize how the entire ecosystem will work together.
I think migrating to ASP.NET Core with Full Framework would be the incremental migration. If you are using OWIN compatible middleware then it’s really about rebuilding your Katana Startup to ASP.NET Core Startup. You can then also switch from self hosting with HttpListener to Kestrel.
I did notice last week that Katana moved to GitHub. I do not see anything that says the Katana will support .NET Core or .NET Standard. I think the reference on the roadmap is that Katana components ultimately turned into .NET components. However this is more of a copy/mutation.
If you want to switch to .NET Core instead of Full Framework, that will be dependent on the middleware and the version of .NET Standard the middleware supports.
https://github.com/dotnet/standard/blob/master/docs/versions.md
I really hate the term “Katana” because it both refers to Microsoft’s host implementation of OWIN support in IIS, OwinHost.exe, self-host support, as well as the collection of nuget packages/libraries that allow a web apop to interface with an OWIN host. You should be able to mix and match these, using other OWIN host applications with Katana Web Application libraries, and vice versa. Most people use “Katana” to refer to the host implementations, even though “Project Katana” really is broader than that. So it took me awhile to understand what was meant by “It is possible to migrate from Katana (Microsoft’s OWIN implementation) to ASP.NET Core” because I immediately thought of Katana in terms of the host implementations. Moving to another host OWIN implementation doesn’t require a change of frameworks, so I was like, what does changing hosts have to do with ASP.NET Core?
Not a critique, but just a rant.