Asp.NET Handlers and Modules
description
Transcript of Asp.NET Handlers and Modules
![Page 1: Asp.NET Handlers and Modules](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/1.jpg)
ASP.NETHandlers & Modules
Session Time: 30-45minutes
By: Sunil Pottumuttu
![Page 2: Asp.NET Handlers and Modules](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/2.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/3.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/4.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/5.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/6.jpg)
HttpHandler - The Extension Based Preprocessor
![Page 7: Asp.NET Handlers and Modules](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/7.jpg)
HttpModule - Event Based Preprocessor
![Page 8: Asp.NET Handlers and Modules](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/8.jpg)
Hook to the Events
![Page 9: Asp.NET Handlers and Modules](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/9.jpg)
Overall Picture
![Page 10: Asp.NET Handlers and Modules](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/10.jpg)
Some Handlers
![Page 11: Asp.NET Handlers and Modules](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/11.jpg)
IIS 7 – Handler Mappings & Demo
![Page 12: Asp.NET Handlers and Modules](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/12.jpg)
IIS 7 – Http Modules & Demo
![Page 13: Asp.NET Handlers and Modules](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/13.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/14.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/15.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/16.jpg)
Imp Http Modules Events
• BeginRequest • AuthenticateRequest • AuthorizeRequest • EndRequest • Error
![Page 17: Asp.NET Handlers and Modules](https://reader035.fdocuments.us/reader035/viewer/2022070320/558656ecd8b42ac23e8b45d8/html5/thumbnails/17.jpg)
Demo Material
Demo Material