DEV 402 Extending the ASP NET Runtime Jurgen
- Slides: 33
DEV 402 Extending the ASP. NET Runtime Jurgen Postelmans Microsoft Regional Director Be. Lux U 2 U
Agenda Role of the Http. Runtime What is the Http. Runtime The Http. Context class Extending the Http. Runtime Http. Modules Global. asax Http. Handlers Hosting the Http. Runtime
demo Using Http. Modules and Http. Handlers
Role of the Http Runtime Pluggable, modular architecture Caching, Security, State Management…. Ability to customize and extend ASP. NET Example: Perform dynamic authorization Example: Take over. xml file extension Reduce need for C/C++ ISAPIs Goal: You can do everything in ASP. NET Use any managed language, including VB. NET
ASP. NET Architecture Inside IIS 5. 0 INETINFO. EXE (IIS 5. 0) aspnet_isapi. dll http: //www. foo. com/bar. aspx ASPNET_WP. EXE Worker Process Named pipes HTTP Request Handler
ASP. NET Architecture Inside IIS 5. 0 App. Pool 1 App. Pool 2 INETINFO WAS metabase Worker Process ASP. NET Filters User Mode Kernel Mode HTTP. SYS
Http Runtime Architecture. asmx . aspx . ashx Session. State Http. Context Http. Runtime Http. Handlers Process Boundary External Session Authentication Output. Cache Http. Modules Cache
Http. Context Everything you needed to know about the current ASP. NET Request but where afraid to ask
About Http. Context The glue that ties the pipeline together Encapsulates all request specific data Instance created for each request System. Web. Http. Context “flows” throughout request lifetime Developers can add to Http. Context. Items collection Objects then flowed throughout request Exposed via static Http. Context. Current Code must be running on original thread
Http. Context Properties Name Type Description Current Http. Context for the current request Application Http. Application. State Appliction-wide property bag Application. Instance Http. Application Context (Modules) Session Http. Session. State Per-client session state Request Http. Request The HTTP Request Response Http. Response The HTTP Response User IPrincipal information Handler IHttp. Handler HTTP Handler that will dispatch the call Items IDictionary Per-request property bag Server Http. Server. Utility URL cracking/sub handlers Error Exception First error occured during processing
demo Using Http. Context
Implementing Http. Modules Participate in every ASP. NET request
Http. Modules Enables developers to: Extend the HTTP Pipeline Examine and modify HTTP Requests Used by ASP. NET: External Session State Http. Module Forms Authentication Http. Module Output Cache Http. Module ….
Http. Runtime Architecture. aspx . asmx . ashx Session. State Http. Context Http. Runtime Http. Handlers External Session Authentication Output Cached Page Output. Cache Http. Modules Cache
Http. Modules What Are Interception Events? Request participation Methods called at specific stages of request Http. Response available Terminate processing of request Http. Application. Complete. Request() Response. End()
Per-Request Application Events Begin. Request Authenticate. Request Authorize. Request Resolve. Request. Cache Aquire. Request. State Pre. Request. Handler. Execute Handler Execution Post. Request. Handler. Execute Release. Request. State Update. Request. Cache End. Request
Creating an Http. Module Class must implement interface: System. Web. IHttp. Module public interface IHttp. Module { public void Init(Http. Application application); public void Dispose(); } Init() Called when module is created Register delegates for runtime events Dispose()
Registering an Http. Module 1. 2. Compile into. NET assembly Deploy Into application’s bin directory or Register in the GAC 3. Register in configuration: <configuration> <system. web> <http. Modules> <add name=“friendly name” type=“class, assembly“ /> </http. Modules> </system. web> </configuration>
Modules vs Global. asax Functionality of global. asax and modules overlap Global. asax supports extra events like Application_Start and Application_End Session_Start and Session_End
demo Writing Modules
Implementing Http. Handlers Taking control of the request target
What are Http. Handlers ? Are the endpoint for a request They actually process the request and generate the response (HTML, XML, …) Similar to ISAPI Extensions Examples: ASP. NET Page Handler (*. aspx) ASP. NET Service Handler (*. asmx) Server-Side XSL Transformer (*. xml) Dynamic image generation
Creating an Http. Handler Class must implement interface: System. Web. IHttp. Handler public interface IHttp. Handler { public void Process. Request(Http. Context context); public bool Is. Reusable(); } Process. Request() ‘Main’ method of the handler Is. Reusable { get; } Indicates whether pooling is supported
Registering an Http. Handler 1. 2. Compile into. NET assembly Deploy Into application’s bin directory or Register in the GAC 3. Register in configuration: <configuration> <system. web> <http. Handlers> <add verb="*" path="myfile. myext" type="class, assembly" /> </http. Handlers> </system. web> </configuration> 4. Important: Extension must be mapped in IIS
demo Writing Handler
demo Writing an Asynchronous Handler
Hosting the Http. Runtime
ASP. NET Hosting Http. Runtime is a clean abstraction Enable non-IIS hosting scenarios System. Web. Hosting namespace Scenarios: Pre-generation of. htm for dynamic pages ASP. NET Cassini server (XP Home) See http: //www. asp. net/Projects/Cassini/ Download/Default. aspx? tabindex=0&tabid=1 for sample source
demo Hosting ASP. NET
Community Resources http: //www. microsoft. com/communities/default. mspx Most Valuable Professional (MVP) http: //www. mvp. support. microsoft. com/ Newsgroups Converse online with Microsoft Newsgroups, including Worldwide http: //www. microsoft. com/communities/newsgroups/default. mspx User Groups Meet and learn with your peers http: //www. microsoft. com/communities/usergroups/default. mspx
Suggested Reading And Resources The tools you need to put technology to work! TITLE Microsoft® ASP. NET Programming with Microsoft Visual C#®. NET Version 2003 Step By Step: 0 -7356 -1935 -6 Available Today Microsoft Press books are 20% off at the Tech. Ed Bookstore Also buy any TWO Microsoft Press books and get a FREE T-Shirt
evaluations
© 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.
- Classic asp to asp.net migration
- Jurgen asp
- Introduction to asp.net
- 大阪 microsoft asp.net
- Asp.net execution model
- Agenda en asp.net
- Asp.net timeline
- Desarrollo de aplicaciones web con asp.net
- Asp.net web api 2
- Imperva waf bypass xss
- Asp custom control
- Reflection net
- Asp.net agenda
- 2160711
- Php to asp.net
- Asp.net introduction
- Asp net core roadmap
- Who is this
- Tutorialspoint dotnet
- Asp.net core soap
- Azure bug bounty
- Feature flags asp net
- Asp.net mvc 5 identity authentication and authorization
- Asp.net server controls
- Crud asp.net c# web forms
- Asp.net session management
- Fromservicesattribute
- Asp net session state
- Asp net core future
- 大阪 microsoft asp.net
- Asp net load testing
- Jürgen polke
- Thumbs dreamstime
- "jurgen ziewe"