Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

application_beginrequest

Status
Not open for further replies.

nooro

Programmer
Feb 7, 2003
22
GB
I want to define an application_beginrequest function within a common include file, which I can then call from each of my aspx pages to log various request variables.

However, I'm having trouble simply understanding what is the best way to go about this. I've tried defining it within an ascx file, but when I view compiler output it's like it's executing it in waaay the wrong place.. am I simply not calling on it in the right way?

I'm using c# (not that this makes any difference)

I realise this is a very general request, but any pointers to a little information on how to go about this kind of thing (if you understand the question :)) would be appreciated..

thx in advance
 
"Include file" is the wrong terminology. It's left over from ASP Classic.

Approach your problem from an object standpoint. What you need is an object (or class) to do your bidding.

Just create a new class. Let's call it 'helper', and the name of your project is 'myProject', so when I want to call on this, I'll just say:

myProject.helper helper = new myProject.helper();

Inside this class, you need to get at the current httpContext in order to "log various request variables", so the following directive is in order:

using System.Web.HttpContext;

You can then access the current request with the current keyword inside the class like so:

//create a string to hold the form variable, requestVar
string requestVar = Current.Request.Form("requestVar");

and so on.

Hope this gets you moving in the right direction. Just cash the terminology "include file", and that will help you get moving towards the new design pattern for .NET.

:)
paul
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top