Sample HttpModule

Now it is time to put everything together into a useful HttpModule. The HttpModule implemented in this chapter is a module to log all unhandled errors to a file. If the log file exceeds a certain size, an event is raised. You then can resize or delete the log file with an event handler implemented in the Global.asax file.

This module logs the time of the error, the error message, and the filename, including the line number that generated the error.

The event raised in the Global.asax file contains extra data in a class derived from the System.EventArgs class. This HttpModule will read its initialization data from either the web.config file or the machine.config file. The initialization data contains the filename, including ...

Get Special Edition Using® Microsoft® ASP.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.