Chapter 15. Server Controls and HttpModules: Creating a Feedback Tracking Module

In This Chapter:

  • Custom Server Controls

  • The Comment Tracking Control

  • HttpModules

  • Add Comment Tracking Automatically

  • Deploying the Application

This chapter teaches you how to write custom server controls and how to add content to pages automatically using HttpModules. The sample application that we will build is a server control that tracks feedback about specific ASP.NET pages. Rather then adding this control to each page that we want to track, we will build an HttpModule that automatically places the control on every page within an application. This way, we can add or remove the feedback tracking control from every page by changing only a couple of lines in the web.config file.

HttpModules allow you to handle events generated by the HttpApplication class in a global manner. HttpModules are similar to ISAPI filters but are much easier to design and implement. With an HttpModule, you can do processing on a request at various stages of the request. Because an HttpModule is a global object, it is used to do things that affect most if not all of the .aspx files in your application. Here is a partial list of things that can be done with an HttpModule:

  • File and user authentication.

  • Maintain a collection of objects to be used by a given user (similar to the Session object).

  • Add a message to the bottom of every page that returns HTML data.

  • Encrypt data for pages of a certain type.

  • Centralize error logging for an application.

An HttpModule has two basic purposes. It provides event handlers for events generated by the Application object, and it can generate events that can be handled by your Global.asax file or the code file behind the Global.asax file. Both of these purposes will be discussed in detail.



ASP. NET Solutions - 24 Case Studies. Best Practices for Developers
ASP. NET Solutions - 24 Case Studies. Best Practices for Developers
ISBN: 321159659
EAN: N/A
Year: 2003
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net