Previous page title

T

tucson

Is there a way to get the page title of the previous page from an HREF link
without using Javascript (something server-side)?

<a
href="javascript:location.href=test.aspx?t='+escape(encodeURIComponent(document.title))">Go to next page</a>

This passes the document title but when I try to get
Request.ServerVariables("HTTP_REFERER"), I get nothing. Window.Open gives me
the same result.
I don't want to pass the referer through a querystring.

Thanks
 
P

Paulus E Kurniawan

To make a cross-page request, you can use a Button or LinkButton server
control and set its PostBackUrl property to the target URL. You can also use
Server.Transfer method. On the target page, you can retrieve the title of the
previous page using:

Page.PreviousPage.Title

Hope this helps.
 
T

tucson

The previous page comes from a 3rd party page (on a different server,
different app. from mine). I have no control over that page whatsoever. They
created a link and all I can do is enter text between the brackets <a
href="[my text here only]">[my text]</a>.
 
S

Scott M.

If the previous page is not part of your application and if they are not
passing data to you (via a post or querystring), then there is no way to get
information about what was in that page. This is the nature of HTTP.

-Scott

tucson said:
The previous page comes from a 3rd party page (on a different server,
different app. from mine). I have no control over that page whatsoever.
They
created a link and all I can do is enter text between the brackets <a
href="[my text here only]">[my text]</a>.


Scott M. said:
You could set up the document title as a page property and then access it
using the new PreviousPage property.

http://msdn2.microsoft.com/en-us/library/ms178139.aspx

-Scott
 
T

tucson

I have control over the querystring, that's the javascript I used below to
pass the document title.
<a
href="javascript:location.href=test.aspx?t='+escape(encodeURIComponent(document.title))">Go to next page</a>

The problem is I need both the document title and the http_referer but I
don't want to pass both through a querystring. I want one of them to be
server-side, if it exists. Using the javascript above,
Request.ServerVariables returns nothing.
If I just use <a href="test.aspx">Go to next page</a>, I can get the HTTP
REFERER but can't get the document.title.

I'm trying to avoid somebody just pasting the URL and getting to the page.

I did a workaround by redirecting them. So, they pass the document.title and
document.url through a querystring (encoded). The landing page captures the
info into a session and then redirects it to another page without the
querystring displayed.

But if somebody looks at the intermediate page URL and pastes some
document.title and document.url that match the requirement, it will still
redirect them to the final page.

It sounds like it's not possible to have both.
Thanks

Scott M. said:
If the previous page is not part of your application and if they are not
passing data to you (via a post or querystring), then there is no way to get
information about what was in that page. This is the nature of HTTP.

-Scott

tucson said:
The previous page comes from a 3rd party page (on a different server,
different app. from mine). I have no control over that page whatsoever.
They
created a link and all I can do is enter text between the brackets <a
href="[my text here only]">[my text]</a>.


Scott M. said:
You could set up the document title as a page property and then access it
using the new PreviousPage property.

http://msdn2.microsoft.com/en-us/library/ms178139.aspx

-Scott


Is there a way to get the page title of the previous page from an HREF
link
without using Javascript (something server-side)?

<a
href="javascript:location.href=test.aspx?t='+escape(encodeURIComponent(document.title))">Go
to next page</a>

This passes the document title but when I try to get
Request.ServerVariables("HTTP_REFERER"), I get nothing. Window.Open
gives
me
the same result.
I don't want to pass the referer through a querystring.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top