Depending on what type of project you are using there are two answers:
For a standard VS2005 web site project, you need to create the new class file in your App_Code folder.
For a web application project, you can create it anywhere in the web app project itself or in a supporting assembly project.
Either way, your class will look something like this:
Code:
public abstract class BasePage : System.Web.UI.Page{
//create protected members for use in the pages
protected void LogPageHit(){
//do stuff here
}
}
You then change the class your pages inherit from:
Code:
public partial class myPage : BasePage {
//somewhere in a method
LogPageHit();
}
This would give you good control over when this method is called. You could also have the base page itself call this method so it always gets called for all pages. If you needed to you could create a base page property such as "NoLog" and set that to false if you don't want to log that particular page. Then the base page could check that before executing the logging functionality. This is of course subject to the order in which things happen. If you put the assignment to disable the logging in the page's constructor then it will be turned off before the page ever starts to process so you'd be safe.
-Peter