How to get the previous page url or name?

K

KK

In ASP.NET is it possible to get the name of the
previous page? for example,

Page1.aspx
Page2.aspx

From page1.aspx, I do a Server.Transfer(Page2.aspx),
Now within Page2.aspx can I get the name of Page1.aspx
(the previous page who called page2.aspx) ?
 
H

Hugo Wetterberg

Use Request.UrlReferrer to get an uri to the page that referred to the
current page. If you use this on a page that will perform postbacks you
will have to get the referrer url if(!IsPostBack) and store it in the
viewstate. Otherwise the referrer information will be lost after the
first postback.

Use Context.Request.UrlReferrer if you are making a custom web control
and not code behind for a page.

/Hugo
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top