Logo
CAR REVIEW
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
PREGNANCY
 
 
Windows XP

Microsoft ASP.NET 4 : HTTP Handlers - The Built-in Handlers

7/8/2011 6:09:18 PM
One of the best examples of custom handling is the Trace handler built into ASP.NET. You turn tracing on in the web.config file by inserting the trace element, <trace enabled=true />. This instructs the ASP.NET runtime to store summaries of the requests going through the site so that they can be viewed for diagnostic purposes.

ASP.NET caches the tracing output in memory. To view the trace results, you surf to the virtual directory managing the site and ask for a specific resource: Trace.axd. Take a look at this Example and you'll see the first entry among all the standard HTTP handlers is for a resource named Trace.axd. The tracing functionality behind ASP.NET falls outside of normal UI processing, so it makes sense that tracing is handled by a custom handler.

When you surf to the Trace.axd resource, the handler renders HTML that looks like the output shown in Figure 1. The processing for this handler is very specific—the handler's job is to render the results of the last few requests.

Figure 1. The output of the Trace.axd handler.


As shown in Figure 2, clicking the View Details link resubmits the request with a parameter id=3 in the query string. This causes the handler to render the details of the third request.

Figure 2. The output of the Trace.axd handler focused on a specific request summary.


Figure 3 shows the Microsoft Internet Information Services (IIS) file mapping for files with the .axd extension. Although you won't really see this aspect until deployment time, it's interesting to observe because it shows how ASP.NET is very versatile in the kinds of requests it can handle. IIS handles Trace.axd requests the same way as any other ASP.NET request. That means IIS will pass requests for resources with an extension of .axd on to ASP.NET. Once inside the ASP.NET pipeline, the web.config file tells ASP.NET to handle the request with the Trace handler.

Figure 3. IIS has a handler mapping for Trace.axd.


If you look through the default web.config file a bit more, you'll see some other critical ASP.NET handlers. As you might expect, source code is banned explicitly from normal clients by default. Notice that files such as *.cs, *.config, and *.vb are handled by the Forbidden handler. If you try to look at source code in a Web browser, ASP.NET returns the page shown in Figure 4 by default.

Figure 4. What happens when you try to view forbidden content.


Remember that ASP.NET's configuration is very malleable and that you can choose to let clients see your source code by one of two means. You can remove the source code extension to ASP.NET mappings in IIS. Alternatively, you can write your own source code viewer handlers and declare them in your application's web.config file.

These handlers plug into the pipeline by implementing IHttpHandler. The next section describes this key interface.
Other -----------------
- Microsoft ASP.NET 4 : ASP.NET Request Handlers
- Microsoft ASP.NET 4 : HttpModules (part 2) - Seeing Active Modules & Storing State in Modules
- Microsoft ASP.NET 4 : HttpModules (part 1) - Existing Modules & Implementing a Module
- Microsoft ASP.NET 4 : The HttpApplication Class and HTTP Modules - Overriding HttpApplication
- Microsoft ASP.NET 4 : Diagnostics and Debugging - Error Pages
- Microsoft ASP.NET 4 : Diagnostics and Debugging - Debugging with Visual Studio
- Microsoft ASP.NET 4 : Diagnostics and Debugging - Application Tracing
- Microsoft ASP.NET 4 : Diagnostics and Debugging - Page Tracing
- Microsoft ASP.NET 4 : Caching and State Management - The Wizard Control: An Alternative to Session State
- Microsoft ASP.NET 4 : Caching and State Management - Tracking Session State
- Microsoft ASP.NET 4 : Caching and State Management - Configuring Session State
- Microsoft ASP.NET 4 : Caching and State Management - Session State and More Complex Data
- Microsoft ASP.NET 4 : Caching and State Management - Introduction to Session State
- Installing and Configuring a Modem : Modifying the Modem’s Advanced Properties
- Installing and Configuring a Modem : Modifying the Modem’s General Properties
- Installing and Configuring a Modem : Working with Different Dialing Locations
- Installing and Configuring a Modem : Installing a Modem & Testing the Modem
- Getting Started with Modem Communications : Modem-to-Modem Communications
- Tuning Windows XP’s Performance : More Optimization Tricks
- Tuning Windows XP’s Performance : Optimizing Virtual Memory
 
 
Most view of day
- Microsoft Content Management Server Development : Validating the HtmlPlaceholderControl (part 3) - Building the Required HTML Placeholder Validator
- Windows Live Services That Make Windows 7 Better (part 5) - Windows Live Essentials
- SQL Server 2008 R2 : Creating and Managing Stored Procedures - Using System Stored Procedures
- Microsoft Lync Server 2010 : Planning for Voice Deployment - Enhanced 911
- Windows Phone 8 : Configuring Basic Device Settings - Passwords and Screen Timeouts (part 4) - Disabling a Password
- Maintaining Desktop Health : Monitoring Reliability and Performance (part 5)
- Microsoft PowerPoint 2010 : Creating New Slides (part 1) - Creating New Slides from the Outline Pane
- Adobe Dreamweaver CS5 : Using Library Items and Server-side Includes (part 6) - Applying Server-Side Includes
- Windows Vista Improvements for Hardware and Driver Troubleshooting
- Microsoft Exchange Server 2010 : Working with SMTP Connectors, Sites, and Links (part 8) - Connecting to Exchange 2003 Routing Groups
Top 10
- Windows Phone 8 : Scheduled Tasks - Scheduled Task API Limitations
- Windows Phone 8 : Scheduled Tasks - Updating Tiles Using a Scheduled Task Agent
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 5) - Editing an Existing To-Do Item
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 4) - Creating the To-Do Item Shell Tile, Saving a To-Do Item
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 3) - Debugging Scheduled Tasks
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 2) - TodoService, TodoItemViewModel
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 1) - TodoItem,TodoDataContext
- Windows Phone 8 : Scheduled Tasks - Using Scheduled Tasks
- Windows Phone 8 : Scheduled Tasks - Background Agent Types
- Windows Phone 8 : Windows Phone Toolkit Animated Page Transitions - Reusing the Transition Attached Properties
 
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro