[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Getting the Referral URL with the Global ASAX?

Posted on 2007-10-11
10
Medium Priority
?
772 Views
Last Modified: 2008-01-09
Hello all.  I need to capture the referring URL and store it somehow in session so I can later use it in my application.  I tried the Session OnStart but it keeps coming up null.  I only want to capture the referring URL once they come to any page in the application then use it later on and store it.  Thanks all.
0
Comment
Question by:sbornstein2
  • 6
  • 4
10 Comments
 
LVL 16

Expert Comment

by:McExp
ID: 20061703
are you using master pages?
0
 
LVL 16

Expert Comment

by:McExp
ID: 20061704
Are you familiar with HTTP Modules?
0
 

Author Comment

by:sbornstein2
ID: 20065495
not using master pages and not familiar with HTTP Modules.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:McExp
ID: 20065534
Ok, well there goes my first two solutions!
0
 
LVL 16

Expert Comment

by:McExp
ID: 20065582
Session onStart is fired before any page state info is loaded into memory. I would sugest that you need the following code in all your pages.

IF (SESSION["Refererer"] == null)
{
  SESSION["Referer"] = Request.Headers.GetValues("HTTP_REFERER");
}

So back to my orignal sugestions, you probablly need to look into writing a HTTP Module that runs for every page and then populates the session variable

http://support.microsoft.com/kb/307996
0
 

Author Comment

by:sbornstein2
ID: 20065867
So there is no way to use the Global.asax to handle that on the load of the application or session?  I did test Session_Start and Application_BeginRequest and it did not work.
0
 
LVL 16

Expert Comment

by:McExp
ID: 20065898
No it won't as all this stuff is initated before any Page state is loaded into memory.
0
 

Author Comment

by:sbornstein2
ID: 20066345
ok cool.  I have something actually already in place and I see what the issue and I am wondering why this happens.  I have a control called ReferringURL and in that I set a Session Varlable to the

string strReferringURL = Request.ServerVariables["HTTP_REFERER"];

the issue it is always null if I come off another domain say for example "www.boston.com" and then I hit one of my localhost pages.  Its null and then it picks up my first localhost page on my domain.  Is that correct that it wont pick up another domain page URL?
0
 
LVL 16

Accepted Solution

by:
McExp earned 1000 total points
ID: 20066518
In my site I track External Referers fine. are you saying that when someone first looks at your page you don't get the Referer populated?

You will only get Referer populated if someone has clicked on a link on another page and that has transfered to you.

If someone directly types in the link (i.e. in the browser bar) you will not get the Referer populated
0
 

Author Comment

by:sbornstein2
ID: 20066571
got ya.  Thanks for all your help, really appreciate it :).
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question