0

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.

stckvrflw
  • 1,489
  • 3
  • 22
  • 37

4 Answers4

0

This is the same problem I have had with the urls. You can use Request.UrlReferrer.ToString() in a page_load sub, but it only works when the page is first loaded. If you do a refresh then it gets the url of the page contained in the pageviewerwebpart instead. I implemented a workaround using cookies. Here is my post over at Sharepoint Stack Exchange: https://sharepoint.stackexchange.com/questions/33617/how-to-get-the-url-name-of-a-subsite-from-a-webpart

Ah, I also found another solution using query parameters, which I mention in my own answer.

Community
  • 1
  • 1
bgmCoder
  • 6,205
  • 8
  • 58
  • 105
0

Have a look at Request.ServerVariables.

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

Jeroen Ritmeijer
  • 2,772
  • 3
  • 24
  • 31
  • 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 Mar 30 '10 at 08:51
  • Not exactly sure what you are after. Are you looking for the HTTP_REFERER server variable? – Jeroen Ritmeijer Mar 30 '10 at 21:06
0

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
  • 10,630
  • 28
  • 36
0

Try Request.ServerVariables["HTTP_REFERER"]. After bit of research I got the url from Request.ServerVariables["HTTP_REFERER"].

Regards, Ajay Raghuwanshi

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72