ASP.NET 3.5 Page Load - Design Issue
<p>I have a web site with a series of Master Pages which all derive from a "Base" master page. For this example lets call it MasterPage.master.</p>

<p><strong>Edit</strong>-----</p>

<p>Basically there are 2 halves of the website: Public and Private. We'd like to create, among other things,  a custom Site Tracking 'utility.' Any time a page is hit... we capture a bunch of data about the user for future reporting, etc.</p>

<p>Right now I am working on the Public site.. but I want to reuse  this 'utility' for the private site 3-4 months from now.</p>

<p>To me, a Master Page doesn't seem like the best way of accomplishing this... While I'm still new to .NET, I feel that Master Pages should only be used for organizing the UI.</p>

<p>I've looked into Custom IHttpModule and have been able to get something to work... but its kinda ghetto if you ask me.</p>

<pre><code>public void Init(HttpApplication context)
    {

        context.AcquireRequestState += (new EventHandler(this.context_AquireRequest));
    }
...
void context_AquireRequest(object sender, EventArgs e)
    {

        HttpApplication application = (HttpApplication)sender;
        HttpContext context = application.Context;

            if (context.CurrentHandler is Page){
                //Do Stuff
            }


    }
</code></pre>

<p><strong>End Edit</strong>----</p>

<p>Is there a better way of having a block of code running each time a page is loaded than the following... Such as a custom IHttpModule or somehow in the Global.asax.</p>

<p>[MasterPage.master]
...</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
    {


        //...do stuff...

    }
</code></pre>

<p>Thanks</p>
