ASP.Net C# URL of the page that redirected to a page

Gezna
Gezna used Ask the Experts™
on
How do I get the url of the previous page in ASP.Net in the code behind (C#).

I need to make a descision in the code based on what page the current page came from.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2008

Commented:
Try this:

PreviousPage.Request.RawUrl

Bob

Author

Commented:
I think I wasn't clear in the question.

I don't know what the previous page is. I need to be able to tell what it is from the current page.
Basically I have two pages (A and B) that link to page C.
In the code behind of page C, I want to know if it got there from A, or from B...
Most Valuable Expert 2012
Top Expert 2008

Commented:
You don't have to know, since that is a construct with 2.0 that gives you that information.  There is the PreviousPage property for the Page provides that for you.

Bob
This is what I did.

Write this code on page load event of the page where you want its referrer.(which page made request)

Response.Write(Request.UrlReferrer.ToString());

It will display the url of previous page

Hope this helps
 
         

Commented:
Response.Write(Request.UrlReferrer.ToString());
it is working on Firefox but on IE it is givng error "Object reference not set to an instance of an object. ".

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial