Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Get url

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tester - 01 Oct 2007 18:45 GMT
How can I get the url of the web page that called my page?  This may be from
a different web app and different web page.  I explored the
page.previouspage, but it only seems to work if in the same application and
even then it doesn't give me the full url.  Thank you for your help.
Alexey Smirnov - 01 Oct 2007 19:13 GMT
> How can I get the url of the web page that called my page?  This may be from
> a different web app and different web page.  I explored the
> page.previouspage, but it only seems to work if in the same application and
> even then it doesn't give me the full url.  Thank you for your help.

You mean where user came from?

Try Request.UrlReferrer
tester - 01 Oct 2007 23:16 GMT
That works!  Thanks.

>> How can I get the url of the web page that called my page?  This may be
>> from
[quoted text clipped - 6 lines]
>
> Try Request.UrlReferrer
Mark Rae [MVP] - 01 Oct 2007 23:28 GMT
>>> How can I get the url of the web page that called my page?  This may be
>>> from
[quoted text clipped - 6 lines]
>>
>> Try Request.UrlReferrer

> That works!  Thanks.

Be aware, though, that you can't rely on this, as more and more ISPs are
stripping HTTP_REFERER from headers...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Alexey Smirnov - 02 Oct 2007 08:04 GMT
> >>> How can I get the url of the web page that called my page?  This may be
> >>> from
[quoted text clipped - 14 lines]
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net

Mark is right, you have to check if (Request.UrlReferrer != null), for
example:

if (Request.UrlReferrer==null) {
// user typed in an URL directly, or used a bookmark
} else {
// user came from other website
}
George Ter-Saakov - 02 Oct 2007 14:15 GMT
Actually, from my "vast" experience
do not use Request.UrlReferrer
instead use Request.ServerVariables["HTTP_REFERER"]

the reason is that UrlReferrer is returning object Uri and it will throw
exception if passed referrer is in incorrect format.
So either be ready that code
if (Request.UrlReferrer != null)
can throw exception or use Request.ServerVariables["HTTP_REFERER"].
It always returns string and usually you do not need to know if it's a valid
http reference or not.
You should check for null anyway.

George.

>> >>> How can I get the url of the web page that called my page?  This may
>> >>> be
[quoted text clipped - 25 lines]
> // user came from other website
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.