Top Banner
ASP.NET Request Processing Internals Abhijit Jana Consultant | Microsoft http://abhijitjana.net
23

ASP.NET Request Processing Internals

Nov 22, 2014

Download

Technology

Abhijit Jana

ASP.NET Request Processing Overview. Presented at Microsoft User Group Hyderabad Community Meet !
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ASP.NET Request Processing Internals

ASP.NET Request Processing Internals

Abhijit JanaConsultant | Microsofthttp://abhijitjana.net

Page 2: ASP.NET Request Processing Internals

Agenda

ASP.NET Request

Processing Internals

Role of Web Server

Page Life Cycle

Internal of Web Server

Request Processing

Request Pipeline

Page 3: ASP.NET Request Processing Internals

Getting Started• 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 Port

Local Development System

Visual Studio

Web Application

ASP.NET Development ServerWebdev.WebServer20.exe Webdev.WebServer40.exe

Page 4: ASP.NET Request Processing Internals

Demo

Page 5: ASP.NET Request Processing Internals

Local Development System

Visual StudioWeb

Application

Local IISWorker Process

Process Request

(w3wp.exe)

Request

Response

Moving to IIS

Page 6: ASP.NET Request Processing Internals

Key ConceptApplication PoolWorker ProcessWeb FarmWeb 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: ASP.NET Request Processing Internals

Application Pool and HTTP.SYS

HTTP.SYS

IIS

Application Pool

W3wp.exe

Application Pool

W3wp.exe

Application Pool

W3wp.exe

ApplicationHost.Config

Page 8: ASP.NET Request Processing Internals

Demo

Page 9: ASP.NET Request Processing Internals

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 10: ASP.NET Request Processing Internals

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: ASP.NET Request Processing Internals

Svchost.exe

Overall View Of IIS

World Wide Web Publishing Service

(WWW service)

Windows Process Activation Service

(WAS)

HTTP.SYS

Application Pool

ApplicationHost.Config

Page 12: ASP.NET Request Processing Internals

Looking bit Inside of Request Processing

HTTP.SYS

IIS

Application Pool

W3wp.exe

Application Pool

W3wp.exe

Application Pool

W3wp.exe

HTTP Module

HTTP Handler HTTP Handler

HTTP Module

HTTP Module

HTTP Module

HTTP Module

Svchost.exe

WWW service WAS

Page 13: ASP.NET Request Processing Internals

Request Processing Continue..• Client Send a Request, HTTP.sys intercepts the request. • HTTP.sys Interacts with WWW Publishing Services and sync

with the related configuration stored in applicationHost.config.

• The WWW Service receives configuration like application pool, virtual directory, site details from applcationHost.config

• WWW Publishing Services gets the request from Http.Sys and passed to WAS

• WAS starts a worker process for the application pool associated with the request was made.

• Workerprocess execute ASP.NET Internals operations• The worker process processes returns a response to

HTTP.sys. • The client receives a response from Server.

Page 14: ASP.NET Request Processing Internals

Inside Worker Process (w3wp.exe)

W3wp.exeaspnet_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

Run

time

Page 15: ASP.NET Request Processing Internals

Demo

Page 16: ASP.NET Request Processing Internals

Inside Worker Process (w3wp.exe) cond..

W3wp.exe

Web Server CoreBeginRequest

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: ASP.NET Request Processing Internals

HTTP PipelineHTTP Module

HTTP Handler HTTP Handler

HTTP Module

HTTP Module

HTTP Module

HTTP Module

• Modules are individual features that the server uses to process requests

• Plug-in / out modules you want on the server or Application Specific.

• customize a server to a specific role in your environment.

• custom modules to replace existing modules or to introduce new features based on application on server specific

• Content Module ( IsapiFilter ,IsapiFilterModule )

• Security Module (BasicAuthenticationModule )

• Caching Module ( HttpCacheModule)• Compression Module

( StaticCompressionModule )

Page 18: ASP.NET Request Processing Internals

ASP.NET RoutingW3wp.exe

Web Server CoreBeginRequest

Routing Module

Authentication

Authorization

Cache Resolution

Handler

Release State

Update Log

End Request Processing

IHandler

Page 19: ASP.NET Request Processing Internals

Once done with HTTP Pipeline

Page_PreInit

Page_Init

Load View StateLoad Post Back

DataPage_Load

Page Post back event

Pre Render

Save View State

Render

Unload

ASP.NET Page Life

Cycle

Page 20: ASP.NET Request Processing Internals

SummaryCl

ient

Sen

d Re

ques

t Server Receives the Request.Request taken care by WWW Services from

HTTP.SYS

Requ

est

com

es t

o W

3wp Loads ISAPI

Deal with HttpApplication, HttpRuntime, HttpContextForward Request for Http Pipeline

HTT

P Pi

pelin

e

Request Passes through number of HTTP Module and reaches to HTTP Handler

Page

Life

Cyc

le

Executes Page Life Cycle Events.Render Content HTMLResponse Back To Client

Page 22: ASP.NET Request Processing Internals

Q/A

Page 23: ASP.NET Request Processing Internals

Thank You !Abhijit Jana

Blog : http://abhijitjana.net http://dailydotnettips.com

Twitter : @AbhijitJana