Browse DevX
Sign up for e-mail newsletters from DevX


Extending ASP.NET with HttpHandlers and HttpModules

Write custom file handlers and filters with ease in ASP.NET that perform special request-handling, or alter requests either before or after they're processed by the ASP.NET engine.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

ASP.NET provides a robust framework for your Web applications. However, at times it becomes necessary to go beyond the out-of-the-box functionality. For example, when you request a resource such as an HTML page or ASP page using the browser, IIS processes that resource based on its file extension. IIS processes ASP pages using a DLL named asp.dll. Similarly, IIS processes ASP.NET (.aspx) pages with the aspnet_isapi.dll. But sometimes you may need to process custom file extensions. Suppose you're developing a Web application that makes frequent use of graphics generated on-the-fly that display charts. You might want those files to use a custom file extension—for example .chart.

ISAPI Extensions and Filters
Before ASP.NET, the only way to process custom file extensions was to write an ISAPI (Internet Service Application Programming Interface) extension or an ISAPI filter. However, writing ISAPI extensions and filters is difficult, requires strong C/C++ skills, and is considered "out of reach" for many programmers. ASP.NET improves the situation greatly. ASP.NET's HttpExtensions and HttpModules provide functionality similar to ISAPI Extensions and ISAPI filters, respectively. Writing HttpHandlers and HttpModules is just a matter of implementing certain interfaces. HttpExtensions let you process a particular extension (or a set of extensions) using custom code.

Similarly, HttpModules let you filter client requests. For example, you could use an HttpModule if you wanted to manipulate the requested URL by changing the file names before letting the ASP.NET engine handle the request—thus hiding the real file names from the clients. Unlike HttpExtensions, HttpModules execute for every request—irrespective of the file extension. You can create an HttpModule to tweak the request either before or after the appropriate handler processes it.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date