views:

126

answers:

2

Hello,

I have a simple hit counter written in c# .net. I placed that counter to many pages using the pageviewerwebpart. What I want to do is, not only counting the hits, but also which page triggered the hit counter. So how can I retrieve the page URL with my hit counter ?

Thanks.

A: 

Have a look at Request.ServerVariables.

You are probably after Request.ServerVariables["URL"].

Muhimbi
This just gives the URL of the program but I need to know web URL that contains my program, so that I can learn which page of my website triggered "/MyProgram/Default.aspx"
stckvrflw
Not exactly sure what you are after. Are you looking for the HTTP_REFERER server variable?
Muhimbi
A: 

The get the url of the page that linked to the current page use:

var referrer = Request.Urlreferrer;

if your app is in say an IFRAME you can check it using

parent.location.href;

this works only when running on the same domain / site url though, because of cross scripting security issues.

Colin