owin and katana

17
OWIN and Katana Udaiappa Ramachandran ( Udai ) //linkedin.com/in/ udair

Upload: udaiappa-ramachandran

Post on 19-Jul-2015

215 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Owin and katana

OWIN and Katana

Udaiappa Ramachandran ( Udai )//linkedin.com/in/udair

Page 2: Owin and katana

Who am I?

• Udaiappa Ramachandran ( Udai )

• CTO, Akumina, Inc.,

• Azure Insider

• Consultant

• New Hampshire Cloud User Group (http://www.meetup.com/nashuaug )

• Focus on Cloud Computing• Windows Azure and Amazon Web Services

• http://cloudycode.wordpress.com

• @nhcloud

Page 3: Owin and katana

Agenda

• ASP.NET

• What is OWIN?

• What is Katana?

• OWIN Projects

• Hosting

• Demo

• References

• Q & A

Page 4: Owin and katana

ASP.NET• ASP.NET runs on single package (System.Web)

• Both ASP.NET and ASP.NET MVC designed to be run on IIS

• ASP.NET Web API is independent of System.Web using new abstraction like HttpRequestMessage and HttpResponseMessage in System.Net.Http. This enables ASP.NET Web API to be self hosted

• Developers cannot configure the Pipeline, framework takes the control and executes the user code in framework pipe line

• Unable to compose multiple frameworks in a single server

Page 5: Owin and katana

What is Open Web Interface for .NET (OWIN)?

• OWIN is a specification ( http://owin.org )

• 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.

• using AppFunc=Func<IDictionary<string,object>, Task>;

• Dictionary uses the owin.* for the core HTTP concepts

Page 6: Owin and katana

OWIN Dictionary KeysKey Name Value Description

"owin.RequestBody"A Stream with the request body, if any. Stream.Null MAY be used as a placeholder if there is no request body. See Request Body.

"owin.RequestHeaders" An IDictionary<string, string[]> of request headers. SeeHeaders.

"owin.RequestMethod" A string containing the HTTP request method of the request (e.g.,"GET", "POST").

"owin.RequestPath"A string containing the request path. The path MUST be relative to the "root" of the application delegate; see Paths.

"owin.RequestPathBase"A string containing the portion of the request path corresponding to the "root" of the application delegate; see Paths.

"owin.RequestProtocol" A string containing the protocol name and version (e.g. "HTTP/1.0" or"HTTP/1.1").

"owin.RequestQueryString"A string containing the query string component of the HTTP request URI, without the leading “?” (e.g., "foo=bar&baz=quux"). The value may be an empty string.

"owin.RequestScheme" A string containing the URI scheme used for the request (e.g., "http","https"); see URI Scheme.

Page 7: Owin and katana

What is Katana?• OWIN implementations for Microsoft servers and frameworks

• Open-source OWIN components from Microsoft include infrastructure components supporting System.Web and System.Net.HttpListener.

• IAppBuilder startup interface plays an important role in the startup sequence in Katana.

• Owin.dll is not considered a part of Katana but Katana components depend on this assembly

• Designed for performance and scalability

• Easy to configure pipeline by composing only the necessary components

• Startup code provided by the developer runs first and assembles the pipeline through which the HTTP requests are run through subsequently

Page 8: Owin and katana

IAppBuilder

Page 9: Owin and katana

Layers• Host

• Startup, Initialization

• Server• Process requests through an OWIN pipeline

• System.Web, Http Listener, Web Listener

• Application framework/Middleware• Expose programming model over OWIN pipleline

• Pass-through components such as AuthN, Logging, etc.,

• SignalR, ASP.NET Web API

• Application• Developers code

Page 10: Owin and katana

Hosting• OwinHost.exe

• Custom Host• Microsoft.Owin.SelfHost

• Hosting on IIS using ASP.NET Request pipeline• Microsoft.Owin.Host.IIS (IIS without ASP.net)

• Microsot.Owin.Host.SystemWeb

Page 11: Owin and katana

OWIN Projects• Servers and Hosts

• Katana• Nowin• Fracture

• Frameworks• Nancy• SignalR• WebApi• FubuMVC• Simple.Web• DuoVia.Http• ACSP.NET

• Implementations• ASP.NET vNext• Katana• Fix• Dyfrig

Page 12: Owin and katana

Locating Startup Code• OwinHost

• Command line argument

• Katana provides hosting API which allows the startup class to be specified WebApp.Start<Startup>(…)

• Looks for config file and takes the appSettings key value of “owin:AppStartup”

• Scans the loaded assemblies for the OwinStartup attribute as follows:• [assembly: OwinStartup( typeof( HelloWorld.MyClass))]

• At this point if host is able to locate more than one OwinStartup attribute specifying different types, the startup discovery process fails because of the ambiguity

• Scanning all the loaded assemblies for the type Startup with a method void Configure(IAppBuilder)

Page 13: Owin and katana

Demo Scenarios• ASP.NET Web API

• Authentication

• StageMarkers

• Extending ASP.NET Applications

• Dependency Injection

• Unit Testing

Page 14: Owin and katana

Summary• Entirely Asynchronous

• Easy to short circuit the pipeline using Run, Use and Invoke

• Explicitly specifying the startup code using the OwinStartup attribute is a good practice.

• Katana hosts stream by default while IIS (System.Web) buffers by default

• Katana allows you to provide an event handler that gets called when the response headers are sent.

• ASP.NET Web API framework, which gets plugged into OWIN pipeline using the extension method UseWebApi

• Easy to unit test using NuGet package Microsoft.Owin.Testing

Page 16: Owin and katana

Q & A

Page 17: Owin and katana

Thank you for attending Nashua CLOUD .NET Usergroup