Logo
Windows XP
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
- Managing Windows 7 : Controlling the Power Options
- Windows Small Business Server 2011 : Adding a Terminal Server - Configuring RemoteApps (part 2) - Deploying with .rdp and .msi files
- Microsoft Visio 2010 : Importing Graphics (part 4) - Adding Excel Charts to Your Diagrams, Importing Vector Graphics
- Maintaining Windows 7 : Back Up Files
- Using Voice and Sounds : Directing Your Computer with Voice Commands, Dictating Text
- SharePoint 2013 : Health and Monitoring (part 2) - Correlation IDs, The Logging Database
- Microsoft Dynamics AX 2009 : Integration with Microsoft Office - Creating Excel files
- Windows Phone 8 : Playing Music Through the Phone (part 2) - The Play Screen,Playing an Album
- Extending Dynamics GP with Free Software : Capturing Screenshots and sending an E-mail for support
- Maintaining Desktop Health : Monitoring Reliability and Performance (part 2)
Top 10
- Windows Server 2012 : Administering Active Directory using Windows PowerShell (part 3) - Performing an advanced Active Directory administration task
- Windows Server 2012 : Administering Active Directory using Windows PowerShell (part 2) - Finding Active Directory administration cmdlets
- Windows Server 2012 : Administering Active Directory using Windows PowerShell (part 1) - Managing user accounts with Windows PowerShell
- Windows Server 2012 : Enabling advanced features using ADAC (part 3) - Creating fine-grained password policies
- Windows Server 2012 : Enabling advanced features using ADAC (part 2) - Configuring fine-grained password policies
- Windows Server 2012 : Enabling advanced features using ADAC (part 1) - Enabling and using the Active Directory Recycle Bin
- Microsoft Excel 2010 : Protecting and Securing a Workbook - Marking a Workbook as Read-Only
- Microsoft Excel 2010 : Protecting and Securing a Workbook - Working with Office Safe Modes
- Microsoft Excel 2010 : Protecting and Securing a Workbook - Setting External Content Security Options
- Microsoft Excel 2010 : Protecting and Securing a Workbook - Setting Privacy Options - Set Parental Controls for Online Research
 
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro