introduction to owin

Post on 14-Jan-2015

395 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

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

INTRODUCTION TO OWIN

Saravanan

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

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>

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.

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

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

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.

ARCHITECTURE CONTD..,

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.

REGISTRATION

Uses the Pre-Application Start to configure 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

SERVER

IIS OwinHost CustomServers

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.

OWIN / IIS PIPELINE STAGES

OWIN Pipeline Stages IIS Pipeline Stages

TRADITIONAL IIS HTTPMODULE

OWIN MIDDLEWARE COMPONENTS [OMC]

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]

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

OWIN IIS PIPELINE

OWIN SELF-HOST

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

Thank you

top related