I have a website with a series of master pages, all of which are produced on the "Base" main page. In this example, you can call MasterPage.master.
Edit -----
Basically there are two halves of the website: public and private. We would like to create, among other things, a special website tracking utility. Every time a page hits ... we collect a bunch of user data for future reports, etc.
Now I work on a public site .. but I want to reuse this "utility" for a private site in 3-4 months.
For me, the main page does not seem to be the best way to do this. Although I'm still new to .NET, I feel that master pages should only be used to organize the user interface.
I studied the custom IHttpModule and was able to get something to work ... but my curious ghetto, if you ask me.
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){
}
}
Edit End ----
Is there a better way to have a code block executed each time a page loads than the following ... For example, a custom IHttpModule or somehow in Global.asax.
[MasterPage.master] ...
protected void Page_Load(object sender, EventArgs e)
{
}
thank
source
share