Inside IIS Request Processing and ASP.NET Page Lifecycle

29
IND 14-16 Dec. Inside IIS Request Processing and ASP.NET Page Lifecycle Abhijit Jana | Consultant | Microsoft http://abhijitjana.net @abhijitjana

description

Topic Covered : ASP.NET Runtime Engine and Visual StudioRole of a Web ServerKey Concepts of IISIIS and ASP.NET Requests ProcessingInside Worker ProcessInternals of Http Pipeline Page Lifecycle Internals

Transcript of Inside IIS Request Processing and ASP.NET Page Lifecycle

Page 1: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Inside IIS Request Processing and ASP.NET Page LifecycleAbhijit Jana | Consultant | Microsofthttp://abhijitjana.net @abhijitjana

Page 2: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

ASP.NET Runtime Engine and Visual Studio Role of a Web Server Key Concepts of IIS IIS and ASP.NET Requests Processing Inside Worker Process Internals of Http Pipeline Page Lifecycle Internals

Agenda

Page 3: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

ASP.NET Runtime Engine and Visual Studio Visual Studio IDE has it own Integrated ASP.NET

Runtime ASP.NET Development Server

WebDev.WebServer20.exe ( CLR 2.0 ) WebDev.WebServer40.exe (CLR 4.0 )

ASP.NET Development Server Runs on Specific PortLocal Development System

Visual Studio

Web Applicatio

n

ASP.NET Development ServerWebdev.WebServer20.e

xeWebdev.WebServer40.e

xe

Page 4: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

DEMOHow Visual Studio Runs ASP.NET Application ?

Page 5: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Moving to IIS

Local Development System

Visual StudioWeb

Application

Local IIS

Worker Process

Process Request

(w3wp.exe)

Request

Response

Page 6: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Key Concepts Application Pool Worker Process Web Farm Web Garden

IISApplication Pool

Worker

Process

Application Pool

Application Pool

Worker

Process

Worker

Process

Web Application 1

Web Application 2

Web Application 3Web Application

4

w3wp

Page 7: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

HTTP.SYS

HTTP.SYS

IIS User Level

Application Pool

W3wp.exe

Application Pool

W3wp.exe

Application Pool

W3wp.exe

ApplicationHost.Config

Page 8: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Protocol Listener [ HTTP.SYS ] Protocol Listener is the part of Kernel Level of IIS Protocol listeners receive protocol-specific requests send them to IIS for processing return responses to requestors It the Kernel mode Protocol stack which listens to the

HTTP and HTTPS Request Kernel-mode caching Kernel Mode Queuing

Page 9: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

DEMORegistering Application Pool

Page 10: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

WWW service and WAS Part of User Level of IIS World Wide Web Publishing Service (WWW service) and

Windows Process Activation Service (WAS) run as Local System in the same Svchost.exe process

Performance Monitoring Processing Monitoring Configuration Management

Svchost.exe

World Wide Web Publishing Service (WWW service)

Windows Process Activation Service (WAS)

HTTP.SYS

Page 11: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Overall View Of IIS in Request Processing

Svchost.exe

World Wide Web Publishing Service

(WWW service)

Windows Process Activation Service

(WAS)

HTTP.SYS

Application Pool

ApplicationHost.Config

Page 12: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Overall View Of IIS in Request Processing

Svchost.exe

World Wide Web Publishing Service

(WWW service)

Windows Process Activation Service

(WAS)

HTTP.SYS

Application Pool

ApplicationHost.Config

Worker Process (w3wp.exe)

HTTP Module

HTTP Module

HTTP Module

HTTP Module

HTTP Module

Page 13: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Application Pool

Inside Worker Process ( w3wp.exe)

W3wp.exe

aspnet_isapi.dll

Http Application

HTTP Module

HTTP Handler HTTP Handler

HTTP Module

HTTP Module

HTTP Module

HTTP Module

HTTPRuntime

HTTPProcessRequest

HTTPContext

HTTP Application

HTTP ApplicationFactory.NET R

unti

me

Page 14: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

DEMOIISAPI Process Request and Application Domain Creation

Page 15: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Inside Worker Process ( w3wp.exe)

ISAPIRuntime.ProcessRequest() HttpRuntime.ProcessReq

uest

Create New Instance of HttpContext

Load HttpApplication Calls

HttpApplication.Init()

Page 16: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

HTTP Application Created By HTTPApplicationFacotry class It’s create pool of HTTPApplication Object

W3wp.exe

Web Server Core

BeginRequest

Modules

Authentication

Authorization

Cache Resolution

Handler

Release State

Update Log

End Request Processing

BasicAuthenticationModule

HttpCacheModule

StaticCompressionModule

DynamicStaticCompressionModule

URL Authorization

Tracing

HTTP Error

HTTP Logging

Page 17: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

HTTPContext.Current.Items

Page 18: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Application

HTTPModule

Handler Factory

HTTPHandler

ASP.NET Page

HTTP Pipeline Request Flow

Page 19: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

DEMOHTTP Application and HTTP Module

Page 20: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

DEMORetrieve Module Specific Information

Page 21: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Page 22: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Svchost.exe

World Wide Web Publishing Service

(WWW service)

Windows Process Activation Service

(WAS)

HTTP.SYS

Application Pool

ApplicationHost.Config

W3wp.exe

Web Server Core

BeginRequest

Modules

Authentication

Authorization

Cache Resolution

Handler

Release State

Update Log

End Request Processing

BasicAuthenticationModule

HttpCacheModule

StaticCompressionModule

DynamicStaticCompressionMod

ule

URL Authorization

Tracing

HTTP Error

HTTP Logging

1

2

3

4

5

6

7

89

10

11

12

Quick Recall !!!

Page 23: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Page 24: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Request Flow in ASP.NET

IIS

Global.aspx

ASP.NET Runtime

HTTPPipeline

ASP.NET Pages

Page 25: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

ASP.NET Page Lifecycle

Page_PreInit

Page_Init

Load View State

Load Post Back Data

Page_Load

Page Post back event

Pre Render

Save View State

Render

Unload

Page 26: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

DEMOInternals of ASP.NET Page Life Cycle

Page 27: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Visual Studio Integrated Web Server Execution Process

Application Pool, Worker Process, Web Farm, Web Garden

User Level and Kernel Level of IIS Application Configuration, SVCHOST.EXE, WWW,

WAS IISAPI Filter, HTTP Module and HTTP Handler ,

Handler Factory HTTP Pipeline, ASP.NET Routing Module Page Life Cycle Internal Events

KEY TAKEAWAY

Page 28: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

Resources

http://msdn.microsoft.com/ http://technet.microsoft.com/

msdnindia technetindia

@msdnindia

@technetindia

SOFTWARE APPLICATION DEVELOPER

INFRASTRUCTURE PROFESSIONALS

Page 29: Inside IIS Request Processing and ASP.NET Page Lifecycle

IND 14-16 Dec.

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Abhijit Jana | Consultant | [email protected] | [email protected] http://abhijitjana.net @abhijitjana

Thank You !