Katana & OWIN
A new lightweight Web server for .NET
Simone Chiaretta
@simonech
http://codeclimber.net.nz
Ugo Lattanzi
@imperugo
http://tostring.it
Agenda
 What is OWIN
 OWIN Specs
 Introducing Katana
 Katana pipeline
 Using Katana
 Building OWIN middleware
 A look at the future
What is OWIN
What is OWIN
OWIN defines a standard interface between .NET web
servers and web applications. The goal of the OWIN interface
is to decouple server and application, encourage the
development of simple modules for .NET web development,
and, by being an open standard, stimulate the open source
ecosystem of .NET web development tools.
http://owin.org
What is OWIN
The design of OWIN is inspired by node.js, Rack (Ruby)
and WSGI (Phyton).
In spite of everything there are important differences between
Node and OWIN.
OWIN specification mentions a web server like something that is
running on the server, answer to the http requests and forward
them to our middleware. Differently Node.Js is the web server that
runs under your code, so you have totally the control of it.
IIS and OS
 It is released with the OS
 It means you have to wait the new release of Windows to
have new features (i.e.: WebSockets are available only on
the latest version of Windows)
 There aren’t update for webserver;
 Ask to your sysadmin “I need the latest version of Windows
because of Web Sockets“
System.Web
 I was 23 year old (now I’m 36) when System.Web was born!
 It’s not so cool (in fact it’s missing in all new FW)
 Testing problems
 2.5 MB for a single dll
 Performance
Support OWIN/Katana
Many application frameworks support OWIN/Katana
 Web API
 SignalR
 Nancy
 ServiceStack
 FubuMVC
 Simple.Web
 RavenDB
OWIN specs
OWIN Specs: AppFunc
using AppFunc = Func<
IDictionary<string, object>, // Environment
Task>; // Done
http://owin.org
OWIN Specs: Environment
Some compulsory keys in the dictionary (8 request, 5 response, 2
others)
 owin.RequestBody – Stream
 owin.RequestHeaders - IDictionary<string, string[]>
 owin.Request*
 owin.ResponseBody – Stream
 owin.ResponseHeaders - IDictionary<string, string[]>
 owin.ResponseStatusCode – int
 owin.Response*
 owin.CallCancelled - CancellationToken
OWIN Specs: Layers
• Startup, initialization and process management
Host
• Listens to socket
• Calls the first middleware
Server
• Pass-through components
Middleware
• That’s your code
Application
Introducing Katana aka Fruit Ninja
Why Katana
 ASP.NET made to please ASP Classic (HTTP req/res object
model) and WinForm devs (Event handlers): on fits all
approach, monolithic (2001)
 Web evolves faster then the FW: first OOB release of
ASP.NET MVC (2008)
 Trying to isolate from System.Web and IIS with Web API
(2011)
 OWIN and Katana fits perfectly with the evolution, removing
dependency on IIS
Katana pillars
 It’s Portable
 Components should be able to be easily substituted for new
components as they become available
 This includes all types of components, from the framework to the
server and host
Katana pillars
 It’s Modular/flexible
 Unlike many frameworks which include a myriad of features that
are turned on by default, Katana project components should be
small and focused, giving control over to the application
developer in determining which components to use in her
application.
Katana pillars
 It’s Lightweight/performant/scalable
 Fewer computing resources;
 As the requirements of the application demand more features
from the underlying infrastructure, those can be added to the
OWIN pipeline, but that should be an explicit decision on the part
of the application developer
Katana Pipeline
Katana Pipeline
Host
IIS
OwinHost.exe
Custom Host
Server
System.Web
HttpListener
Middleware
Logger
WebApi
And more
Application
That’s your
code
Using Katana
Hello Katana: Hosting on IIS
Hello Katana: Hosting on IIS
Hello Katana: Hosting on IIS
public void Configuration(IAppBuilder app)
{
app.Use<yourMiddleware>();
app.Run(context =>
{
context.Response.ContentType = "text/plain";
return context.Response.WriteAsync("Hello Paris!");
});
}
Changing Host: OwinHost
Changing Host: OwinHost
Changing Host: Self-Host
Changing Host: Self-Host
static void Main(string[] args)
{
using (WebApp.Start<Startup>("http://localhost:9000"))
{
Console.WriteLine("Press [enter] to quit...");
Console.ReadLine();
}
}
Real World Katana
 Just install the framework of choice and use it as before
Real World Katana: WebAPI
Real World Katana: WebAPI
public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute("default", "api/{controller");
app.UseWebApi(config);
}
Katana Diagnostic
install-package Microsoft.Owin.Diagnostics
Securing Katana
 Can use traditional cookies (Form Authentication)
 CORS
 Twitter
 Facebook
 Google
 Active Directory
OWIN Middleware
OWIN Middleware: IAppBuilder
 Non normative conventions
 Formalizes application startup pipeline
namespace Owin
{
public interface IAppBuilder
{
IDictionary<string, object> Properties { get; }
IAppBuilder Use(object middleware, params object[] args);
object Build(Type returnType);
IAppBuilder New();
}
}
Building Middleware: Inline
app.Use(new Func<AppFunc, AppFunc>(next => (async env =>
{
var response = environment["owin.ResponseBody"] as Stream;
await response.WriteAsync(Encoding.UTF8.GetBytes("Before"),0,6);
await next.Invoke(env);
await response.WriteAsync(Encoding.UTF8.GetBytes(“After"),0,5);
})));
Building Middleware: raw OWIN
using AppFunc = Func<IDictionary<string, object>, Task>;
public class RawOwinMiddleware
{
private AppFunc next;
public RawOwinMiddleware(AppFunc next)
{
this.next = next;
}
public async Task Invoke(IDictionary<string, object> env)
{
var response = env["owin.ResponseBody"] as Stream;
await response.WriteAsync(Encoding.UTF8.GetBytes("Before"),0,6);
await next.Invoke(env);
await response.WriteAsync(Encoding.UTF8.GetBytes(“After"),0,5);
}
}
Building Middleware: Katana way
public class LoggerMiddleware : OwinMiddleware
{
public LoggerMiddleware(OwinMiddleware next) : base(next)
{}
public override async Task Invoke(IOwinContext context)
{
await context.Response.WriteAsync("before");
await Next.Invoke(context);
await context.Response.WriteAsync("after");
}
}
A look at the future
Project K and ASP.NET vNext
 Owin/Katana is the first stone of the new ASP.NET
 Project K where the K is Katana
 Microsoft is rewriting from scratch
 vNext will be fully OSS (https://github.com/aspnet);
 MVC, WEB API and SignalR will be merged (MVC6)
 It uses Roslyn for compilation (build on fly)
 It runs also on *nix, OSx
 Cloud and server-optimized
 POCO Controllers
OWIN Succinctly
Soon available online on
http://www.syncfusion.com/resources/techportal/ebooks
Demo code
https://github.com/imperugo/ncrafts.owin.katana
Merci
Merci pour nous avoir invités à cette magnifique
conférence.

More Related Content

PPTX
OWIN and Katana Project - Not Only IIS - NoIIS
PPTX
Owin and katana
PPTX
Introduction to OWIN
PPTX
Angular Owin Katana TypeScript
PPTX
ASP.NET: Present and future
PPT
OWIN (Open Web Interface for .NET)
PPTX
Owin from spec to application
OWIN and Katana Project - Not Only IIS - NoIIS
Owin and katana
Introduction to OWIN
Angular Owin Katana TypeScript
ASP.NET: Present and future
OWIN (Open Web Interface for .NET)
Owin from spec to application

What's hot (20)

PPTX
Mini-Training Owin Katana
PDF
Asp.Net Core MVC , Razor page , Entity Framework Core
PPTX
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
ODP
Developing Microservices using Spring - Beginner's Guide
PPT
Technology Radar Talks - NuGet
PPTX
Getting Started with Spring Boot
PPTX
Microservices Platform with Spring Boot, Spring Cloud Config, Spring Cloud Ne...
PPTX
ASP.NET vNext ANUG 20140817
PDF
Microservices with Java, Spring Boot and Spring Cloud
PPTX
Introduction to ASP.NET Core
PPTX
Debugging your Way through .NET with Visual Studio 2015
PPTX
Full stack development with node and NoSQL - All Things Open - October 2017
PPTX
Introducing ASP.NET vNext - A tour of the new ASP.NET platform
PDF
Introduction to ASP.NET Core
PPTX
Building Angular 2.0 applications with TypeScript
PPTX
ASP.NET Core 1.0 Overview
PPTX
Spring Boot & WebSocket
ODP
Integrating Apache Syncope with Apache CXF
PPT
Spring Boot. Boot up your development. JEEConf 2015
PPTX
Testing Microservices
Mini-Training Owin Katana
Asp.Net Core MVC , Razor page , Entity Framework Core
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Developing Microservices using Spring - Beginner's Guide
Technology Radar Talks - NuGet
Getting Started with Spring Boot
Microservices Platform with Spring Boot, Spring Cloud Config, Spring Cloud Ne...
ASP.NET vNext ANUG 20140817
Microservices with Java, Spring Boot and Spring Cloud
Introduction to ASP.NET Core
Debugging your Way through .NET with Visual Studio 2015
Full stack development with node and NoSQL - All Things Open - October 2017
Introducing ASP.NET vNext - A tour of the new ASP.NET platform
Introduction to ASP.NET Core
Building Angular 2.0 applications with TypeScript
ASP.NET Core 1.0 Overview
Spring Boot & WebSocket
Integrating Apache Syncope with Apache CXF
Spring Boot. Boot up your development. JEEConf 2015
Testing Microservices
Ad

Viewers also liked (10)

PDF
Nodejs for .NET web developers
PPTX
Real-Time Web Applications with ASP.NET WebAPI and SignalR
PPTX
Docker for .NET Developers
PPTX
DevIntersections 2014 Web API Slides
PPTX
Real World Asp.Net WebApi Applications
PPTX
Micro Services in .NET Core and Docker
PDF
How to Make Own Framework built on OWIN
PDF
web apiで遊び倒す
PPTX
Web API or WCF - An Architectural Comparison
PDF
Web 2.0 Business Models
Nodejs for .NET web developers
Real-Time Web Applications with ASP.NET WebAPI and SignalR
Docker for .NET Developers
DevIntersections 2014 Web API Slides
Real World Asp.Net WebApi Applications
Micro Services in .NET Core and Docker
How to Make Own Framework built on OWIN
web apiで遊び倒す
Web API or WCF - An Architectural Comparison
Web 2.0 Business Models
Ad

Similar to Owin and Katana (20)

PDF
Node.js Workshop
PPTX
ASP.NET Core 1.0
PPTX
AJppt.pptx
PPTX
A Brief History of OWIN
PDF
Devoxx 2018 - Pivotal and AxonIQ - Quickstart your event driven architecture
PPTX
Introducing ASP.NET Core 2.0
PDF
Jax WS JAX RS and Java Web Apps with WSO2 Platform
PDF
OWIN Why should i care?
PPTX
Owin katana en
PPTX
Node.js primer for ITE students
PPTX
SWOFT a PHP Microservice Framework - 2020
PPTX
Advance Java Topics (J2EE)
PDF
Play Framework: async I/O with Java and Scala
PPTX
Best of Microsoft Dev Camp 2015
PDF
WSO2 AppDev platform
PDF
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
PDF
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
KEY
Play Support in Cloud Foundry
PPTX
Node.js Workshop
ASP.NET Core 1.0
AJppt.pptx
A Brief History of OWIN
Devoxx 2018 - Pivotal and AxonIQ - Quickstart your event driven architecture
Introducing ASP.NET Core 2.0
Jax WS JAX RS and Java Web Apps with WSO2 Platform
OWIN Why should i care?
Owin katana en
Node.js primer for ITE students
SWOFT a PHP Microservice Framework - 2020
Advance Java Topics (J2EE)
Play Framework: async I/O with Java and Scala
Best of Microsoft Dev Camp 2015
WSO2 AppDev platform
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Play Support in Cloud Foundry

Recently uploaded (20)

PDF
A review of recent deep learning applications in wood surface defect identifi...
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PPTX
2018-HIPAA-Renewal-Training for executives
PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
PPT
Geologic Time for studying geology for geologist
PPTX
Configure Apache Mutual Authentication
PDF
Architecture types and enterprise applications.pdf
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
Flame analysis and combustion estimation using large language and vision assi...
PPT
Module 1.ppt Iot fundamentals and Architecture
PPTX
The various Industrial Revolutions .pptx
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PPTX
Chapter 5: Probability Theory and Statistics
DOCX
search engine optimization ppt fir known well about this
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Hindi spoken digit analysis for native and non-native speakers
A review of recent deep learning applications in wood surface defect identifi...
Final SEM Unit 1 for mit wpu at pune .pptx
2018-HIPAA-Renewal-Training for executives
Microsoft Excel 365/2024 Beginner's training
Zenith AI: Advanced Artificial Intelligence
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
Geologic Time for studying geology for geologist
Configure Apache Mutual Authentication
Architecture types and enterprise applications.pdf
The influence of sentiment analysis in enhancing early warning system model f...
Flame analysis and combustion estimation using large language and vision assi...
Module 1.ppt Iot fundamentals and Architecture
The various Industrial Revolutions .pptx
A proposed approach for plagiarism detection in Myanmar Unicode text
Chapter 5: Probability Theory and Statistics
search engine optimization ppt fir known well about this
Benefits of Physical activity for teenagers.pptx
Getting started with AI Agents and Multi-Agent Systems
Hindi spoken digit analysis for native and non-native speakers

Owin and Katana

  • 1. Katana & OWIN A new lightweight Web server for .NET Simone Chiaretta @simonech http://codeclimber.net.nz Ugo Lattanzi @imperugo http://tostring.it
  • 2. Agenda  What is OWIN  OWIN Specs  Introducing Katana  Katana pipeline  Using Katana  Building OWIN middleware  A look at the future
  • 4. What is OWIN OWIN defines a standard interface between .NET web servers and web applications. The goal of the OWIN interface is to decouple server and application, encourage the development of simple modules for .NET web development, and, by being an open standard, stimulate the open source ecosystem of .NET web development tools. http://owin.org
  • 5. What is OWIN The design of OWIN is inspired by node.js, Rack (Ruby) and WSGI (Phyton). In spite of everything there are important differences between Node and OWIN. OWIN specification mentions a web server like something that is running on the server, answer to the http requests and forward them to our middleware. Differently Node.Js is the web server that runs under your code, so you have totally the control of it.
  • 6. IIS and OS  It is released with the OS  It means you have to wait the new release of Windows to have new features (i.e.: WebSockets are available only on the latest version of Windows)  There aren’t update for webserver;  Ask to your sysadmin “I need the latest version of Windows because of Web Sockets“
  • 7. System.Web  I was 23 year old (now I’m 36) when System.Web was born!  It’s not so cool (in fact it’s missing in all new FW)  Testing problems  2.5 MB for a single dll  Performance
  • 8. Support OWIN/Katana Many application frameworks support OWIN/Katana  Web API  SignalR  Nancy  ServiceStack  FubuMVC  Simple.Web  RavenDB
  • 10. OWIN Specs: AppFunc using AppFunc = Func< IDictionary<string, object>, // Environment Task>; // Done http://owin.org
  • 11. OWIN Specs: Environment Some compulsory keys in the dictionary (8 request, 5 response, 2 others)  owin.RequestBody – Stream  owin.RequestHeaders - IDictionary<string, string[]>  owin.Request*  owin.ResponseBody – Stream  owin.ResponseHeaders - IDictionary<string, string[]>  owin.ResponseStatusCode – int  owin.Response*  owin.CallCancelled - CancellationToken
  • 12. OWIN Specs: Layers • Startup, initialization and process management Host • Listens to socket • Calls the first middleware Server • Pass-through components Middleware • That’s your code Application
  • 13. Introducing Katana aka Fruit Ninja
  • 14. Why Katana  ASP.NET made to please ASP Classic (HTTP req/res object model) and WinForm devs (Event handlers): on fits all approach, monolithic (2001)  Web evolves faster then the FW: first OOB release of ASP.NET MVC (2008)  Trying to isolate from System.Web and IIS with Web API (2011)  OWIN and Katana fits perfectly with the evolution, removing dependency on IIS
  • 15. Katana pillars  It’s Portable  Components should be able to be easily substituted for new components as they become available  This includes all types of components, from the framework to the server and host
  • 16. Katana pillars  It’s Modular/flexible  Unlike many frameworks which include a myriad of features that are turned on by default, Katana project components should be small and focused, giving control over to the application developer in determining which components to use in her application.
  • 17. Katana pillars  It’s Lightweight/performant/scalable  Fewer computing resources;  As the requirements of the application demand more features from the underlying infrastructure, those can be added to the OWIN pipeline, but that should be an explicit decision on the part of the application developer
  • 23. Hello Katana: Hosting on IIS public void Configuration(IAppBuilder app) { app.Use<yourMiddleware>(); app.Run(context => { context.Response.ContentType = "text/plain"; return context.Response.WriteAsync("Hello Paris!"); }); }
  • 27. Changing Host: Self-Host static void Main(string[] args) { using (WebApp.Start<Startup>("http://localhost:9000")) { Console.WriteLine("Press [enter] to quit..."); Console.ReadLine(); } }
  • 28. Real World Katana  Just install the framework of choice and use it as before
  • 30. Real World Katana: WebAPI public void Configuration(IAppBuilder app) { HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute("default", "api/{controller"); app.UseWebApi(config); }
  • 32. Securing Katana  Can use traditional cookies (Form Authentication)  CORS  Twitter  Facebook  Google  Active Directory
  • 34. OWIN Middleware: IAppBuilder  Non normative conventions  Formalizes application startup pipeline namespace Owin { public interface IAppBuilder { IDictionary<string, object> Properties { get; } IAppBuilder Use(object middleware, params object[] args); object Build(Type returnType); IAppBuilder New(); } }
  • 35. Building Middleware: Inline app.Use(new Func<AppFunc, AppFunc>(next => (async env => { var response = environment["owin.ResponseBody"] as Stream; await response.WriteAsync(Encoding.UTF8.GetBytes("Before"),0,6); await next.Invoke(env); await response.WriteAsync(Encoding.UTF8.GetBytes(“After"),0,5); })));
  • 36. Building Middleware: raw OWIN using AppFunc = Func<IDictionary<string, object>, Task>; public class RawOwinMiddleware { private AppFunc next; public RawOwinMiddleware(AppFunc next) { this.next = next; } public async Task Invoke(IDictionary<string, object> env) { var response = env["owin.ResponseBody"] as Stream; await response.WriteAsync(Encoding.UTF8.GetBytes("Before"),0,6); await next.Invoke(env); await response.WriteAsync(Encoding.UTF8.GetBytes(“After"),0,5); } }
  • 37. Building Middleware: Katana way public class LoggerMiddleware : OwinMiddleware { public LoggerMiddleware(OwinMiddleware next) : base(next) {} public override async Task Invoke(IOwinContext context) { await context.Response.WriteAsync("before"); await Next.Invoke(context); await context.Response.WriteAsync("after"); } }
  • 38. A look at the future
  • 39. Project K and ASP.NET vNext  Owin/Katana is the first stone of the new ASP.NET  Project K where the K is Katana  Microsoft is rewriting from scratch  vNext will be fully OSS (https://github.com/aspnet);  MVC, WEB API and SignalR will be merged (MVC6)  It uses Roslyn for compilation (build on fly)  It runs also on *nix, OSx  Cloud and server-optimized  POCO Controllers
  • 40. OWIN Succinctly Soon available online on http://www.syncfusion.com/resources/techportal/ebooks
  • 42. Merci Merci pour nous avoir invités à cette magnifique conférence.