Reputation: 150
I need event that runs before or on every request made on server.
If that event exist I need to run some code on that event.
For example: Someone types http://www.website.com/some-link
I need to check this link before on before it's processed by application.
I am using C# web forms.
So far I am trying to find event in Global.asax.cs, something like
protected virtual void Application_BeginRequest(object sender, EventArgs e)
{
// need to track requested url
// code that needs to be run with requested url.
}
Is there any proper solution for this situation?
Tnx
Upvotes: 1
Views: 3841
Reputation: 1904
the proper solution would be to use the event Application_BeginRequest, unless you want to complicate things and use httpmodules wich I wouldn't recommend.
protected virtual void Application_BeginRequest(object sender, EventArgs e)
{
var url = Request.Url.AbsoluteUri;
var path = Request.Url.AbsolutePath;
var host = Request.Url.Host;
// your magic goes here
}
just as some information the order of all events is:
Upvotes: 12