In this chapter
Sometimes it is necessary to perform an action every time an ASP.NET page is rendered. An example of this would be authenticating the user accessing the page. User authentication can be implemented in ASP.NET code, but if you forget to implement it on a page, you potentially have a security hole in your application. Additionally, if the file being accessed is not an ASP file, you cannot implement security for it. Versions of ASP prior to ASP.NET did not address this issue. If you needed to perform an action for every user request, you had to write an Internet Server Application Programming Interface (ISAPI) filter. Although ISAPI filters are very powerful, they are not trivial to write and can be written only in C++. This issue is addressed in ASP.NET with the concept of HttpModules. Because HttpModules are part of ASP.NET, they can be written in any of the .NET languages. Any programmer capable of writing ASP.NET code can implement an HttpModule in the programming language of their choice. In this chapter, you will learn how to implement and use an HttpModule. Examples are given in both Visual Basic .Net and C#.