Asp.NET Handlers and Modules

17
ASP.NET Handlers & Modules Session Time: 30- 45minutes By: Sunil Pottumuttu

description

Basic understanding of ASP.NET HANDLERS and MODULES

Transcript of Asp.NET Handlers and Modules

Page 1: Asp.NET Handlers and Modules

ASP.NETHandlers & Modules

Session Time: 30-45minutes

By: Sunil Pottumuttu

Page 2: Asp.NET Handlers and Modules

Agenda

• Introduction• The Problem• Extension Based Preprocessor• Event Based Preprocessor• Overall Picture • Steps to Implement• The Final Output

Page 3: Asp.NET Handlers and Modules

IIS & ASP.NETRequest Workflow

Application

HTTPResponse

asp.dll

aspnet_isapi.dll

*.asp

*.asmx

HTTPRequest

Process Request

Web.configMachine.config

IISIIS

Page 4: Asp.NET Handlers and Modules

ASP.NET Configuration

• Machine.config defines default handlers or handler factories to manage requests

• Web.config may alter Machine.config settings at the application level

Page 5: Asp.NET Handlers and Modules

Machine.config Overrides Web.config

<httpHandlers> <add verb=“GET" path="*.xml" type=“DotNetDashboard.Web.FileDownloadHandler, DotNetDashboard.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxx"/> <add verb="*" path=“displayImage.aspx" type=“DotNetDashboard.Web.ImageFormatter, DotNetDashboard.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxx” /> <add verb="*" path=“*.xls” type="System.Web.HttpForbiddenHandler"/></httpHandlers>

<httpHandlers> <add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory"/> <add verb="*" path="*.asmx" type="System.Web.Services.Protocols.WebServiceHandlerFactory, System.Web.Services, …/><add verb="*" path="*.soap" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory,

System.Runtime.Remoting, …/> <add verb="*" path="*.config" type="System.Web.HttpForbiddenHandler"/></httpHandlers>

Page 6: Asp.NET Handlers and Modules

HttpHandler - The Extension Based Preprocessor

Page 7: Asp.NET Handlers and Modules

HttpModule - Event Based Preprocessor

Page 8: Asp.NET Handlers and Modules

Hook to the Events

Page 9: Asp.NET Handlers and Modules

Overall Picture

Page 10: Asp.NET Handlers and Modules

Some Handlers

Page 11: Asp.NET Handlers and Modules

IIS 7 – Handler Mappings & Demo

Page 12: Asp.NET Handlers and Modules

IIS 7 – Http Modules & Demo

Page 13: Asp.NET Handlers and Modules

Synchronous vs Asnchronous• synchronous request, the

ProcessRequest method is executed, and any markup produced is sent to the browser once the entire request is processed• BeginProcessRequest and the

EndProcessRequest

Page 14: Asp.NET Handlers and Modules

Virtual File Provider

• Global.asax provides hooks into the events of the ASP.NET pipeline just like an httpModule

• Global.asax provides is the capability to add handlers to events not available to modules, like Session_Start and Session_End.

• httpModules have over Global. asax is the ability to compile modules into class libraries that can be used in multiple ASP.NET web sites

Page 15: Asp.NET Handlers and Modules

Modules vs Global.asax

• synchronous request, the ProcessRequest method is executed, and any markup produced is sent to the browser once the entire request is processed• BeginProcessRequest and the

EndProcessRequest

Page 16: Asp.NET Handlers and Modules

Imp Http Modules Events

• BeginRequest • AuthenticateRequest • AuthorizeRequest • EndRequest • Error

Page 17: Asp.NET Handlers and Modules

Demo Material

Demo Material