Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to OWIN


Published on

A brief introduction to OWIN and Katana, the basics and few basic details on the analysis of the internal workings of OWIN and functions, the middleware registrations and how they all compare to the traditional request processing pipelines.

Published in: Technology
  • Be the first to comment

Introduction to OWIN

  1. 1. INTRODUCTION TO OWIN Saravanan
  2. 2. AGENDA  OWIN Introduction  OWIN and Katana  Inspiration  Architecture  Application Startup & Registrations  Hosting Methods  Servers  Request processing Pipelines  Modules / Middlewares  Hosting  OWIN IIS Pipeline  OWIN Self-Hosting
  3. 3. OWIN & KATANA  Open web Interface for .Net  Spec is here  Katana: A Microsoft implementation of OWIN  Not a replacement for ASP.Net / SignalR or WebAPI. Just offers hosting methods.  Reduced interaction between the server and the applications  Application delegate: Func<IDictionary<string, object>, Task>
  4. 4. INSPIRATION  RACK  Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call  Node.js  Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non- blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
  5. 5. INTRODUCTION  Minimal, modular and adaptable interface for developing web applications  Exposes a wrapper for Http requests and http responses  Single method call to handle  Web Servers  Middleware  Web Applications
  6. 6. OWIN  To decouple server and the web applications  Defines the structure and requirements of HTTP request and response interactions  Support for applications in any platform Example  Kayak => runs on nix systems using Mono
  7. 7. ARCHITECTURE Application: Because Katana is not a replacement for ASP.NET but rather a new way to compose and host components, existing ASP.NET Web API and SignalR applications remain unchanged, as those frameworks can participate in an OWIN pipeline. In fact, for these kinds of applications, Katana components will be visible only in a small configuration class. Middleware: The name given to all of the components that handle requests in an OWIN pipeline. It can range from a simple compression component to a complete framework such as ASP.NET Web API, though from the server’s perspective, it’s simply a component that exposes the application delegate. Server: Responsible for binding to a TCP port, constructing the environment dictionary and processing requests through an OWIN pipeline. Host: The process that runs the application. Can IIS or standalone executable. The host is responsible for startup, loading of other OWIN components and shutting down gracefully.
  9. 9. APPLICATION START-UP  IDictionary<string, object> creation and populates any startup data or capabilities provided by the host.  Server selection [owinhost or iis]  Location of the application setup code and invokes it with the Properties collection.  Reads and/or sets configuration in the Properties collection, constructs the desired request processing pipeline, and returns the resulting application delegate.  Invokes the server startup code with the given application delegate and the Properties dictionary.  The server finishes configuring itself, starts accepting requests, and invokes the application delegate to process those requests.
  10. 10. REGISTRATION  Uses the Pre-Application Start to configure OWIN
  11. 11. HOSTING METHODS Details IIS Pipeline Integration OWIN pipeline Supported by IIS Katana.exe Modules HttpModules OMC [OWIN middleware Components] OWIN Startup Via OwinHttpModule Startup Stage based code plugin Via IIS pipeline stages Via Stage markers
  12. 12. SERVER  IIS  OwinHost  CustomServers
  13. 13. WHY HAVE PIPELINES [SOC]  Authentication: Plug-in various authentication mechanisms. How do I validate this OAuth, HTTP Basic Authentication, name/password?  Authorisation: "is the user authorized to perform this particular task?", i.e. role-based security.  Caching: have I processed this request already, can I return a cached result?  Performance & Usage Monitoring: what stats can I get from the request and response?  Execution: actually handle the request and provide a response.
  14. 14. OWIN / IIS PIPELINE STAGES OWIN Pipeline Stages IIS Pipeline Stages
  17. 17. OWIN MIDDLEWARE  Grouping and ordering of the modules  Are run for each request  Similar to that of a HttpMessageHandler [subscribes to each request] Sample Middlewares  Static file renderers  WebAPI  Nancy [web framework for mono]
  18. 18. ENVIRONMENT  All states, including  application state,  request state,  server state etc,  are held in the IDictionary<string, object> object specified on the application delegate.  This is passed from component to component as a request progresses through the pipeline  No specific .NET object model, such as those of HttpContextBase in ASP.NET MVC or HttpRequestMessage/HttpResponseMessage in ASP.NET Web API
  20. 20. OWIN SELF-HOST
  21. 21. MORE INFORMATION  OWIN:  OWIN Spec:  Katana:  Katana Documentation:
  22. 22. Thank you