How to explain Katana and OWIN in simple words and uses? - asp.net

I have read many articles about the OWIN and Katana projects, but I could not get the whole picture of it.
For a normal web developer who uses ASP.NET:
What exactly is OWIN and what problems does it solve (in simple words). What is its relation to IIS?
Does OWIN replace IIS? if not, in what situations does OWIN best fit?
How could OWIN help me in my daily work projects?
How could OWIN help me in a self-improvement projects?

Regarding the comment above, OWIN is not a framework. OWIN is a specification on how web servers and web applications should be built in order to decouple them and allow movement of ASP.NET applications to environments which were not supported before.
Prior to OWIN, when building ASP.NET application, you were inherently bound to IIS due to the heavy dependency on System.Web assembly.
System.Web is something that has existed ever since ASP (non .NET version) and internally contains many things that you might not even need (such as Web Forms or URL Authorization), which by default all run on every request, thus consuming resources and making ASP.NET applications in general lot slower than its counterparts such as Node.js for example.
OWIN itself does not have any tools, libraries or anything else. It is just a specification.
Katana on the other hand, is a fully developed framework made to make a bridge between current ASP.NET frameworks and OWIN specification. At the moment, Katana has successfully adapted the following ASP.NET frameworks to OWIN:
Web API
Signal R
ASP.NET MVC and Web Forms are still running exclusively via System.Web, and in the long run there is a plan to decouple those as well.
On the other hand, IIS is a good, resourceful host for web servers. Entire ASP.NET performance issues using IIS has deep roots in System.Web only. Up until the recent time, when deciding how will you host your web server, you had two options:
IIS
Self-Host
So if you wanted a performance, you'd go for a self-host option. If you wanted a lot of out-of-the-box features that IIS provides, you'd go for IIS but you'd lose on performance.
Now, there is a 3rd option, a Microsoft library named Helios (current codename) which intends to remove System.Web out of the way, and allow you to use IIS on more "cleaner" way, without any unnecessary libraries or modules. Helios is now in pre-release version, and is waiting for more community feedback in order to make it fully supported Microsoft product.
Hope this explanation clarifies things better for you.
EDIT (Sep 2014):
With ASP.NET vNext being in development, Katana is slowly getting retired. Version 3.0 will most likely be last major release of Katana as a standalone framework.
However, all the concepts introduced with Katana are being integrated into ASP.NET vNext, meaning that programming model will be pretty much the same. Quote from forum post made by David Fowler (Architect of ASP.NET vNext):
vNext is the successor to Katana (which is why they look so similar).
Katana was the beginning of the break away from System.Web and to more
modular components for the web stack. You can see vNext as a
continuation of that work but going much further (new CLR, new Project
System, new http abstractions).
Everything that exists today in Katana will make it's way into vNext.
EDIT (Feb 2015):
ASP.NET vNext is now known as ASP.NET 5 and will be built on top of .NET Core 5. .NET Core 5 is lightweight factored version of .NET Framework, designed to support goals of ASP.NET 5 and .NET Native. However, ASP.NET 5 will be supported by .NET Framework 4.6 as well, that should become available together with .NET Core 5. Both ASP.NET 5 and .NET Core 5 will be licensed under MIT and will accept community contributions.
EDIT (May 2015):
Additionally, ASP.NET Web API brand will be discontinued, however it's technology will be base for new ASP.NET MVC 6. Previous ASP.NET MVC versions were built by implementing IHttpHandler, an interface defined in System.Web. ASP.NET MVC 6 removes that dependency, making it portable to various platforms and web servers.
EDIT (May 2016):
ASP.NET 5 will officially be renamed to ASP.NET Core starting with Release Candidate 2 that is scheduled to be released soon. Same will apply for Entity Framework 7 which will be renamed to Entity Framework Core. More information about official announcement and reasons behind it can be found on Scott Hanselman's blog post:
ASP.NET 5 is dead - Introducing ASP.NET Core 1.0 and .NET Core 1.0
EDIT (May 2016):
With the release of Release Candidate 2, ASP.NET Core has been modified so that future web apps are actually just .NET Core console apps setup to process incoming HTTP requests. This concept makes ASP.NET Core even more aligned with approach Microsoft has taken with microservices architecture support and its implementation through Azure Service Fabric. More information on can be found on official blog post:
Announcing ASP.NET Core RC2

If I have to define OWIN for myself, that would be: "The best ideas from the Ruby and Node.js web dev communities, coming to .NET"
But this would not help any ASP.NET developer. My own definition would be something along the lines of:
OWIN defines a standard interface between .NET web servers and web applications. The goal of the OWIN interface is to decouple server and application
If I have to answer the questions you've posed, then here it is:
OWIN is an interface specification. It decouples a web applications from IIS.
If you are using ready-made components (which is what Katana is), then some parts of the application functionality are much easier to implement compared compared to old ASP.NET. Authentication with third-party identity providers (Facebook, Twitter) is one example of this.
OWIN is essentially a collection of best practices, which have been proven in web development communities. It shows a way to implement web apps which is very open to extensibility. As each web developer should constantly be on the cutting edge of new technologies, this is one way to stay up to date with the whole web development community and not just .NET. If you learn OWIN, it would be much easier to learn other web development frameworks like Express for node.js or Rack for Ruby, because the practices they use are similar.

I will try to cover it from the practical perspective.
Katana is project name to implement OWIN in Microsoft.
What exactly is OWIN and what problems does it solve (in simple words). What is its relation to IIS?
OWIN (Open Web Interface for .NET) is a standard (OWIN Specification) and Katana is .NET library, you can get nuget from here. OWIN and Katana became somewhat synonymous on the web.
Before OWIN your only option was IIS with OWIN you can use any other application (that has entry point) as web server.
Does OWIN replace IIS? if not, in what situations does OWIN best fit?
No it does not replace IIS, you can use OWIN and IIS there's Microsoft.Owin.Host.SystemWeb nuget for that. It is best fit if you want to optimise/change the way it is handled in IIS, or you want to create your custom web server out of let's say Windows Forms Application.
How could OWIN help me in my daily work projects?
It could reduce your server running costs since your web servers do not need to run on IIS (Windows) anymore (Windows servers are more expensive than Unix based ones, and you could run it on Console Application under Mono in Linux).
How could OWIN help me in a self-improvement projects?
Learning Microsoft.Owin (and other related OWIN libraries) will improve your knowledge on how HTTP communication between client and web server works.
Good read if you want to understand more on what Katana and OWIN is.

What is OWIN?
OWIN stands for Open Web Interface for .NET. OWIN is a specification that describes how web development frameworks such as ASP.NET MVC should interact with the web servers. The goal of OWIN is to decouple web applications from the web server by introducing an abstraction layer. Such an abstraction enables you to run the same application on all the web servers that support OWIN. Additionally, it simplifies the overall system because the abstraction layer can provide a lightweight infrastructure to host the applications. IIS provides a rich set of features to the web applications. However, web applications may not need all these features. It might be sufficient for them to have minimal HTTP processing capabilities. OWIN compatible host can provide such a hosting environment to these applications. Moreover, you can define a pipeline of modules that are used during the request processing. An OWIN pipeline is a chain of OWIN compatible components through which a request passes.
What is Katana?
Katana is a set of components by Microsoft built using OWIN specifications. Some of these components include Web API, ASP.NET Identity and SignalR.
Above is extract from CodeGuru Article : http://www.codeguru.com/csharp/.net/net_asp/overview-of-owin-and-katana.htm

Related

Do i need ASP.Net core if I have no plans to host my app anywhere other than IIS

I am going to start a ASP.Net project tomorrow.
ASP.Net with Web API, Angular 2 are in my plans, but I am concerned about .Net core as my project life time will be 3 years.
Here's my view of your situation if you do not have any future plans to migrate from Windows platform.
I do not have much experience with .Net Core, but I think .NET framework can offer much more than .NET core a this point. It's more tested, it's older which means it is probably more stable and not prone to changes as younger libraries.
Example for, Entity Framework Core is still missing some features which are offered in standard Entity Framework.
I'm not saying that this will not change, just trying to describe current situation.
For more detailed help, I guess you should post more information about your project.
The AspNetCoreModule has to be installed on your server and is part of the ASP.NET Core Server Hosting Bundle.
For detail information of installing and configuration. Please visit the following website.
https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS
Actually you can use ASP.NET Core with full .net framework. You're not obligated to use it in a combination with dotnet core.
In the end it depends on how much weight you give to the different arguments.
Generally speaking I vote for ASP.NET Core especially for a new project. You will never know how long the lifetime of the project will be (maybe the anticipated three years will be extended). I list some arguments that came to my mind - and some of them will gain or loose some weight over time.
Pros for ASP.NET Core
Faster. The ASP.NET Core Team and the community put much effort to make ASP.NET Core one of the fastest Web Frameworks. It is the first time I have heard that people are proud of some benchmarks.
New framework and in active development with a faster and more fine tuned release cycle. I expect new features to appear on ASP.NET Core faster then (if at all on classic ASP.NET).
Although Cross-Plattform is not necessary for you now - it will be easier for you to make the move (e.g. Linux) in the future.
Starting on Windows you can run you application on top off the full .net framework and use the magnitude of third party libraries.
Pros for ASP.NET (classic)
Robust - many years of experience in production
Feature complete (compared to ASP.NET Core, Entity Framework Core, .core)
Because of its lifetime you will find more people with indepth knowledge

Distinction between Kestrel and Katana

My understanding is currently you can self host WebAPI using Katana, and MVC will have this capability in a future version. Essentially Katana will be a hosting option available to both MVC and WebAPI.
Kestrel has entered the picture, and I see a few MS employees blogging about it demonstrating hosting ASP.NET vNext on Linux.
My understanding is that both Kestrel and Katana implement the OWIN pipeline.
From there it is all a bit fuzzy. I ask myself, why has Kestrel entered the picture, when it seems Katana could serve the same purpose if you compiled it with mono and made some efforts to make it cross platform compatible(perhaps easier said than done).
Do Kestrel and Katana serve the same purpose? Or is one specialized in some way that the other is not?
Will Kestrel eventually be a viable choice for Windows deployments? Or will it be specialized for non-Windows environments and Katana still the choice for Windows?
I recognize that I'm possibly asking for an apple to oranges comparison due to my lack of knowledge of Katana/Kestrel, but if the answer is "Oranges have more of an acidic taste than apples" then that IMO is a perfectly valid answer.
Katana is Microsoft's OWIN implementation and also includes some middleware components for security/authentication, serving static files, and a few other things.
Kestrel is Microsoft's cross-platform development web server that can be used with ASP.NET 5.
ASP.NET 5 does not implement OWIN, but has a "bridge" to enable OWIN components to be used in ASP.NET 5 applications, including running on Kestrel.
I still don't get a clear picture after reading other answers under this question, so I made some research and here's my conclusion:
OWIN is a specification, which defines an programming interface between a web server(like Kestrel and the ones provided by Katana) and a web application(the code by you).
Kestrel comes from ASP.NET Core. It's a OWIN compatible web server.
Katana comes from ASP.NET 4.X. It's a set of things of Microsoft's OWIN implementation, including OWIN servers.
Last but not least:
ASP.NET 5 is dead and replaced by ASP.NET Core. So don't mention it any more.
(Update at 2019/06/28: "Today, we’re announcing that the next release after .NET Core 3.0 will be .NET 5" - BY MS https://devblogs.microsoft.com/dotnet/introducing-net-5/. That means there will be ASP.Net 5, which is in fact the next generation of ASP.Net Core)
OWIN is the key/essential thing in both ASP.NET 4.X and ASP.NET Core.
For more, you may read https://www.quora.com/Is-ASP-NET-Core-a-replacement-for-OWIN-Katana
May be an old question, but since a quick google search led me here i think no one else asked a similar question.
Quoting ASP.NET 5 Documentation:
Kestrel
Kestrel is a cross-platform web server based on libuv, a cross-platform asynchronous I/O library. Kestrel is open-source, and you can view the Kestrel source on GitHub. You add support for Kestrel by including “Kestrel” in your project’s dependencies listed in project.json.
Choosing a server
If you intend to deploy your application on a Windows server, you should run IIS as a reverse proxy server that manages and proxies requests to Kestrel. If deploying on Linux, you should run a comparable reverse proxy server such as Apache or Nginx to proxy requests to Kestrel.
For self-hosting scenarios, such as running in Service Fabric, we recommend using Kestrel without IIS. However, if you require Windows Authentication in a self-hosting scenario, you should choose WebListener.
So, my understanding is: If Kestrel was only a development server, its not anymore and is somehow replacing Katana and OWIN.
"Project Katana" includes Microsoft adding support to IIS for OWIN, creating OwinHost.exe, and providing libraries to allow application to interface with a self hosting WebAPI. Some of these libraries such as Microsoft.Owin.Security are used by ASP.NET MVC 5 (not ASP.NET Core) to wire up identity/authentication through OWIN, but MVC 5 does not support self hosting(although it is possible using other tools). The SelfHosting library is only intended for WebAPI.
So "Katana" is a broad term referring to both host implementations as well as web application support for OWIN: "These components include both infrastructure components, such as hosts and servers, as well as functional components, such as authentication components and bindings to frameworks such as SignalR and ASP.NET Web API."
You may see phrases like "Migrate from Katana to ASP.NET Core" which refere to the web application side. Meaning abandoning the Microsoft.Owin libraries, and using ASP.NET Core which has full OWIN support built in without the need for additional libraries. Or you may see a similar phrase which means moving off of a Katana host to another host such as Kestrel. Unfortunately the term is used to refere to either side of the implementation with little clarification, and you'll have to pay attention to the context of the discussion.
Kestrel is just a host implementation. Its goal is to provide OWIN hosting support across many platforms. It is more lightweight, and not as full featured or mature as IIS. It is recommended to use it behind a reverse proxy of a more secure and rebust web server such as IIS, Apache, nginx, or other. Kestrel is what Microsoft's current documentation recommends as a host to deploy ASP.NET Core web application's on other platforms such as Linux.
If you create an ASP.Net Core project, then Kestrel is currently included by default. It is supported on the same platforms that ASP.NET Core supports.

When should I use OWIN Katana?

I am new to OWIN and Katana. I really don't get why I should use OWIN, while I can use IIS. To simplify, my question is: What do I lose if I skip learning OWIN and use IIS for my websites?
I googled but there is not a simple explanation. There is some information here, but they use some jargon phrases so I cannot understand it.
In asp.net WebApi v2, the OWIN pipeline becomes the default. It is eventually going to be the standard pipeline under any asp.net project.
I cannot put it better than what is written here : http://www.asp.net/aspnet/overview/owin-and-katana/an-overview-of-project-katana
The section "The Open Web Interface for .NET (OWIN)" explains perfectly the goals of OWIN.
Without OWIN, the asp.net bits are coupled to the way IIS communicates with the application. OWIN abstracts web servers and framework components. That means that your application code will now be aware of the OWIN interface, but not of the webserver that is serving the request.
In return, applications can be more easily ported between hosts and potentially entire platforms/operating systems. For example, the ability to host an application in a console or any process allows Mono to host it without efforts... (Raspberry Pi anyone)
The second aspect is that it works as a pipeline.
You can plug any middlewares (and as many as you want) between the webserver and your application.
This allows for more modular solutions. You can develop redistributable middlewares that can impact the request/response coming to/from your application, but keep these modules separated from the application code.
To persuade yourself of the benefits of this modular approach, take a look at the nuget packages available for OWIN : http://www.nuget.org/packages?q=owin
A lot of these packages were previously core asp.net functionality, and have been extracted as middleware.
For example, adding support to login using various OAuth providers becomes an infrastructure concern (a middleware) and does not need to be part of your application code anymore :
http://www.nuget.org/packages/Microsoft.Owin.Security.Google/
http://www.nuget.org/packages/Microsoft.Owin.Security.Facebook/
http://www.nuget.org/packages/Microsoft.Owin.Security.ActiveDirectory/
...
Or if you want to automatically replace all the images from your website by cute cat images, you can do that transparently as well :
https://github.com/serbrech/Owin.Catify
EDIT : It is now available as a nuget package : Owin.Catify!
public interface OWIN
{
void ListenHttpCallAndServeWebPage();
}
namespace Microsoft.OWIN
{
public class Katana : OWIN
{
public void ListenHttpCallAndServeWebPage()
{
// listen to a port for HTTP call and serve web page
}
}
}
Yes, thats right. OWIN is an interface and Katana is an implementation of OWIN interface by Microsoft. Therefore we hear these 2 words (OWIN / KATANA) together and manytimes we get confused between the difference between these 2 terms. So, Katana is Microsoft's implementation of OWIN interface. Say there is another company named BIG-BOSS who wanted to create their own implementation of OWIN, they can do that and name their implementation as 'BATANA' and advertise phrases like OWIN / BATANA.
So, why OWIN !!!
Think about a country where the only vehicle available for movement is a truck. Nothing else. If you want to buy a vehicle, you would buy truck. Well, that used to serve good but people started to realize that, they don't need truck all the time, especially when they want to go to watch a movie or buy milk, driving a heavy truck not only costs high fuel, but also add stress on driving. But yes, if they want to carry lots of heavy stuff, truck serves the purpose very well.
Then, the Government of that country came up with a specification for vehicle makers. The specification is as follows:
A vehicle needs to have 4 wheels
A vehicle must have a steering.
A vehicle must have headlight and signal lights.
So, based on these specifications, anyone can make vehicle according to different needs and they can name their vehicle accordingly. Therefore, Sedan, Pickup Truck, SUV, VAN, ..etc.. all kind of vehicle showed up in the market. If someone does not need to carry heavy stuff all the time, rather needs a vehicle just for going to workplace, he/she can buy a little Sedan. Someone can buy SUV if he needs little more power.
Based on the above example, we can say that our ASP.NET Web application uses System.Web Assembly which is heavily loaded (like a truck) and if we want to make a little Web Application where our purpose is just to serve some files based on a little set of requests, we are bound to use that heavy System.Web assembly (truck). Now, OWIN shows up. OWIN is a set of specification (we can call it interface) that defines a Server. Based on that specification, someone (like a vehicle maker) can make various kind of servers based on specific problem domains / application needs. Microsoft created their own Implementation for OWIN named Katana in the same way which can serve Web API. As WebAPI is a light weight technology, which does not need full blown System.Web things, a light weight Server implementation (like Katana) can boost the performance heavily when you use Web Api hosted on Katana.
Now, if you ask, 'Do I need it' ? Answer is, 'It depends on your need of performance'. If you don't mind driving your truck even for going to watch a movie, then, perhaps you do not need OWIN. But if you feel that, a light weight Sedan car is all you need to drive within a city, small distance, watch movie..etc.. yes, You may check what implementations of OWIN available in the market. Katana is one of the implementations of OWIN, therefore you can check what Katana offers. Not only Katana, if any other company implements OWIN according to specific Domain (for example, a server for Medical Devices which will download latest medicine information) and if you are a doctor, perhaps, you can check that implementation of OWIN. Moreover, you yourself can create your own implementation of OWIN targeting any specific niche.
In terms of web applications, if you are a simple Web developer, developing custom Websites for your clients, perhaps, you do not need to worry about custom implementation of OWINs, because IIS will serve you in a balanced way. If you build a Web API project, you will get Katana based template ready made from Visual Studio -> New Project, so you won't have to worry about anything other than learning Katana specific techniques. At this moment, Katana is not mature enough to completely replace the need for IIS for ASP.NET MVC, but perhaps, in the future it will.
Then When I may need to write my own OWIN Implementation ?
Answer: Well, say for example, you have developed a Windows application which should run as a server in the background and listen to a port number XXXX. Your server will respond to only some set of Requests like this:
GET Inventory
DELETE Inventory ID=4
PUT Inventory ID=5
That's all. And nothing else. So, why would you need a full IIS web server for this little task? You can create your own OWIN implementation in that case. (Perhaps, you will use Katana for that)
Ok, so I understood that, if I want to make a ASP.NET MVC website, I don't have the option to replace IIS, then why should I need to know about Katana at this moment ?
Answer: Even though Katana is not mature enough to replace the need of IIS so that you can host your ASP.NET MVC website directly on Katana, but Katana implemented many cool interfaces of OWIN so that you can take the advantage of using those features side by side. For example, allowing your users to login using Facebook, Google, Twitter etc was not very easy before. Katana gives you many hooks (as a middle-ware) so that you can let Katana take care of external Social Media based Authentication easily without writing plumbing code. There are many other benefits to using Katana that you may find out when you start using this technology.
A simpler version of that answer is that Katana is gong to fully replace System.Web assembly and the old ASP.NET pipeline, which gives you both better flexibility (use it in more scenarios and use only the parts you like) and performance.
So everyone should watch its evolution now and be ready to switch when it is finally completed.
Below is a diagram I drew to fill in the details Microsoft fails to include in this article.
OWIN is such a standard that it let application frameworks run upon it and forget about everything beneath it. On the other hand, OWIN itself utilizes various host adapters to make sure it can talk to the underlying web servers (IIS and many others).
I am now working with the Jexus web server author to investigate how we can write a host adapter to bridge OWIN/Katana and Jexus. We are really happy to learn that OWIN is flexible and highly customizable.
Reference:
http://blog.lextudio.com/2014/06/why-owin-matters-a-lot-for-asp-net-developers/
Why I should use OWIN, while I can use IIS?
OWIN is designed to decouple web servers from the frameworks you work under. It can make the applications lightweight and portable for the mixing frameworks and servers.
And Katana is Microsoft’s implementation of OWIN components.
Since last few years Microsoft is making web tools more agile and responsive as the their plan is progressing. For an example, the development of ASP.Net MVC and ASP.Net Web API. They do not depend on System.Web dll which is a huge burden they feel now I think. Advantage is both developments fixes can be provided on a timely manner and the cycle is faster than ever. Also now developers can deploy these applications on custom OWIN hosts or Katana, which is a reference of OWIN implementation.
What's the point after all?
Microsoft has released a project which is a lightweight OWIN based web host on top of IIS, called `Helios. The goal is to avoid ASP.NET/IIS relationship by providing some independent small components that can be used, installed and manage independently running on a web-host that implements the OWIN specifications.
One of the core reasons is the performance-factor. Helios will be able to achieve 2x-3x more throughput than standard ASP.Net application. In terms of memory consumption, Helios is much better than System.Web dll. In a taken benchmark Helios architecture allowed a sample application to achieve 50000 concurrent requests with approximately 1GB less overhead compare to a standard ASP.Net application.
OWIN is an abstraction between the web application and the hosting platform. If you write your web application using OWIN you are not tied to IIS, you can use another host if you like.
You asked why use OWIN rather than IIS, but these are not alternatives to each other. OWIN sits between IIS and your application so that you can switch out IIS without rewriting your application.
You might also like to check out this page https://github.com/Bikeman868/OwinFramework/wiki/OWIN

can i use wcf rest service in my asp.net 3.5 web application

I heard that rest services are moved from wcf to asp.net web api frame work.
Our web application is built on vs 2010 (asp.Net 3.5) .So still i can use wcf rest services in my web application?
Please suggest some alternatives if it is not possible.
WCF can still be used to build RESTful services1, many services are already built with it and it's not going away. What you heard is that most of the new developments in terms of new functionality in the area by Microsoft will be made in the ASP.NET Web API framework, not in WCF. But as all the services out there can attest, WCF for building web services is still a valid alternative, if it does all you need.
1 The official name is actually "WCF Web HTTP Services"; REST is a well-defined set of constraints which need to be implemented, which would give the service some useful properties. There are some people who argue that people should stop using the term REST for all HTTP-based, non-SOAP services.

Are these usages of OWIN possible?

Is it possible to write a simple custom Console Application that includes a owin library that can host a Asp.Net Web Application directly (without katana.exe, like CassiniDev's library)?
Is it possible to let an Asp.Net Web Application including MVC 4, Web API, SignalR features hosted across IIS and owin, without / rarely changing code?
For hosting applications from the ASP .NET framework family on top of OWIN, as of this post, you can do so with WebAPI and SignalR. If you need something more like MVC and Razor, you can look at using the NancyFX web app framework for that. Maybe in future versions of MVC OWIN support will be enabled
I did an initial implementation of adapter at https://github.com/ashmind/Gate.Adapters.AspNet.
It is absolutely not production ready, but if the functionality is important for you you are welcome to test/extend it.
As far as I know there is no other reliable library for that.

Resources