devylzangel Posted October 31, 2003 Posted October 31, 2003 I know this is a simple thing, usually, but for some reason I just can't figure out how to do it: On my Page_Load Event (.vb side), I need to capture the URL from the previous (referring) page and hold it in a variable or in a label that is not visible on my page. An example: I got to http://www.yahoo.com and click on Yahoo! Auctions. On the Page_Load Event of the Yahoo! Auctions page, I need to set myurl = http://www.yahoo.com. Can anyone tell me how to do this using VB.NET? Quote
bri189a Posted October 31, 2003 Posted October 31, 2003 I know what your talking about, I've done it in the past, just can't find the code, check MSDN under the window or document object; one of those if I remember right has a property for the previous page... sorry that's all I got, someone I'm sure will give you the exact though. Quote
Moderators Robby Posted October 31, 2003 Moderators Posted October 31, 2003 If the previous page is always from your own server then have a look at this sample... http://www.xtremedotnettalk.com/showthread.php?s=&threadid=78434 Quote Visit...Bassic Software
*Gurus* Derek Stone Posted October 31, 2003 *Gurus* Posted October 31, 2003 [msdn=System.Web.HttpRequest]Request.UrlReferrer[/msdn] Quote Posting Guidelines
devylzangel Posted November 3, 2003 Author Posted November 3, 2003 (edited) I have tried using Request.UrlReferrer and I always get an error. Below is the code I used: Private myurl As Uri myurl = Request.UrlReferrer 'in my page_load event Response.Redirect(myurl.AbsoluteUri) 'button_click event I am probably way off base an completely wrong in the way that I am trying to do this, but I found an article on msdn where they said to do it this way. The error that I get says that the Object reference is not set to an instance of an object (my favorite error...). When stepping through the code in debug mode, I see that when I am tryiing to set the myurl variable, it is = to nothing. Does anyone know what I'm doing wrong? Edited November 3, 2003 by devylzangel Quote
*Gurus* Derek Stone Posted November 3, 2003 *Gurus* Posted November 3, 2003 Unless Request.UrlReferrer is a null reference then Response.Redirect(Request.UrlReferrer.ToString()) should work. Being as you mentioned a null reference exception it is highly likely a HTTP_REFERRER header wasn't set by the client, either because of a firewall, a proxy server, or some other filter or intermediary. Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.