473,327 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

URL of referring/calling page

Hi !

How do I get the URL of the page which has called the current page.
Say PageA.aspx calls PageB.aspx. How do I get PageA's url from the
Pre_Init function of PageB. I tried something like

Request.UrlReferrer.ToString()

But it gives me an Object not instantiated error.

Same with Request.ServerControls[HTTP_REFERER]

How can I get the previous page url ? Please help soon !

Thanks !

Apr 11 '07 #1
5 11498

Zeba wrote:
How do I get the URL of the page which has called the current page.
Say PageA.aspx calls PageB.aspx. How do I get PageA's url from the
Pre_Init function of PageB. I tried something like

Request.UrlReferrer.ToString()

But it gives me an Object not instantiated error.
Hi,
The simple test shows that the task with the conditions you discribed
(PageA.aspx calls PageB.aspx) always returns Request.UrlReferrer!=null
and it cannot generate the "Object not instantiated" error.
So I guess the problem is in something you did not mention.
There are 2 cases when it can happens:
1. You calls PageB.aspx by the means of javascript:
<a href="javascript:window.open('PageB.aspx');void(0) ;"...
In this case try to change link:
<a href="PageB.aspx" target="_blank" ...

2. PageA.aspx is a secure page. (https://...../PageA.aspx). Honestly,
I am not sure you can get information about PageA.aspx anyway.

Apr 11 '07 #2
On Apr 11, 6:55 pm, "marss" <marss...@gmail.comwrote:
Zeba wrote:
How do I get the URL of the page which has called the current page.
Say PageA.aspx calls PageB.aspx. How do I get PageA's url from the
Pre_Init function of PageB. I tried something like
Request.UrlReferrer.ToString()
But it gives me an Object not instantiated error.
Hi,
My PageB is not called through javascript. PageA is not secure either.
So what could be the reason for the error ? This statement is given in
the pre-init function. Could that be the reason ?
Thanks!
>
Hi,
The simple test shows that the task with the conditions you discribed
(PageA.aspx calls PageB.aspx) always returns Request.UrlReferrer!=null
and it cannot generate the "Object not instantiated" error.
So I guess the problem is in something you did not mention.
There are 2 cases when it can happens:
1. You calls PageB.aspx by the means of javascript:
<a href="javascript:window.open('PageB.aspx');void(0) ;"...
In this case try to change link:
<a href="PageB.aspx" target="_blank" ...

2. PageA.aspx is a secure page. (https://...../PageA.aspx). Honestly,
I am not sure you can get information about PageA.aspx anyway.

Apr 11 '07 #3
"Zeba" <co******@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
Request.UrlReferrer.ToString()

But it gives me an Object not instantiated error.

Same with Request.ServerControls[HTTP_REFERER]
Do you mean Request.ServerVariables...?
How can I get the previous page url ? Please help soon !
There is no reliable way of doing this through headers:
http://www.google.co.uk/search?sourc...%22+unreliable
Apr 11 '07 #4

Zeba wrote:
Hi,
My PageB is not called through javascript. PageA is not secure either.
So what could be the reason for the error ?
I don't know. Type of UrlReferrer is Uri. It creates based on the url
of PageA.aspx. But there are a lot of cases when it can not be
created. Look here for UriFormatException:
http://msdn2.microsoft.com/en-us/library/ceyeze4f.aspx
I am not sure, it is only idea.
>This statement is given in
the pre-init function. Could that be the reason ?
Replace the code to Page_Load and test.

Regards.

Apr 11 '07 #5
Noting there are several ways to defeat the use of the HTTP_REFERER variable
it can be used reliably on one's own site but does require a click event to
populate the variable with data. So don't call. Click :-)

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/

"Zeba" <co******@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
Hi !

How do I get the URL of the page which has called the current page.
Say PageA.aspx calls PageB.aspx. How do I get PageA's url from the
Pre_Init function of PageB. I tried something like

Request.UrlReferrer.ToString()

But it gives me an Object not instantiated error.

Same with Request.ServerControls[HTTP_REFERER]

How can I get the previous page url ? Please help soon !

Thanks !

Apr 11 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jenkins | last post by:
I have a page with frames. The left frame is a list of urls. The main frame is loaded based on the url that was clicked in the left frame. Is there a way for the main frame to tell which url was...
2
by: Mike Brearley | last post by:
I was wondering if there was an easy way to have a form set up so that when the submit button is pressed, it goes to a confirmation page that contains a back button that goes back to the page that...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
3
by: George | last post by:
VS.NET 2002\Web\VB I am trying to get the referring URL for one of my pages using this: Request.UrlReferrer.ToString Page 1 has a link to Page 2. I click on the link in Page 1, and go to...
2
by: buran | last post by:
Dear ASP.NET Programmers, I want to store the referring page of an .aspx page so that I can redirect the user back to the referring page if needed. I am using the following code snippet but...
3
by: Dan Sikorsky | last post by:
How can I get the Querystring passed to the Referring Page from its referrer? I don't want the querystring coming to my current page. I want the querystring that came to the referring page, so...
5
by: Christina | last post by:
I can't seem to find any reference for grabbing the title of the referring page, which I want to use for creating a link. i.e. document.write ("Our thanks to <a href='"+document.referrer+"'>"...
2
by: paladin | last post by:
We have a strange situation where some of the referring URL's are missing from our log files. This is on .NET application on IIS 6.0. Here is what is happening: Page a.aspx has a form that...
4
by: CG | last post by:
Hi I need to implement some low level security that locks a certain page if the user does come from a particular link (which is hosted on another domain). I've considered using HTTP_REFERER...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.