introduction to owin

22
INTRODUCTION TO OWIN Saravanan

Upload: saran-doraiswamy

Post on 14-Jan-2015

395 views

Category:

Technology


1 download

DESCRIPTION

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.

TRANSCRIPT

Page 1: Introduction to OWIN

INTRODUCTION TO OWIN

Saravanan

Page 2: Introduction to OWIN

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

Page 3: Introduction to OWIN

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>

Page 4: Introduction to OWIN

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.

Page 5: Introduction to OWIN

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

Page 6: Introduction to OWIN

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

Page 7: Introduction to OWIN

ARCHITECTUREApplication: 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.

Page 8: Introduction to OWIN

ARCHITECTURE CONTD..,

Page 9: Introduction to OWIN

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.

Page 10: Introduction to OWIN

REGISTRATION

Uses the Pre-Application Start to configure OWIN

Page 11: Introduction to OWIN

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

Page 12: Introduction to OWIN

SERVER

IIS OwinHost CustomServers

Page 13: Introduction to OWIN

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.

Page 14: Introduction to OWIN

OWIN / IIS PIPELINE STAGES

OWIN Pipeline Stages IIS Pipeline Stages

Page 15: Introduction to OWIN

TRADITIONAL IIS HTTPMODULE

Page 16: Introduction to OWIN

OWIN MIDDLEWARE COMPONENTS [OMC]

Page 17: Introduction to OWIN

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]

Page 18: Introduction to OWIN

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

Page 19: Introduction to OWIN

OWIN IIS PIPELINE

Page 20: Introduction to OWIN

OWIN SELF-HOST

Page 21: Introduction to OWIN

MORE INFORMATION

OWIN: http://owin.org/ OWIN Spec: http://

owin.org/spec/owin-1.0.0.html Katana: https://katanaproject.codeplex.com/ Katana Documentation: https://

katanaproject.codeplex.com/documentation

Page 22: Introduction to OWIN

Thank you