Click here to Skip to main content
15,878,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every body,

I have problem that,
in my web project that i can go to specific page from many page.
I want to know what is the name of the previous page when i go to the specific page

Because i have certain code inside the specific page that i want to execute only when the previous page is home page.

I want to write code like that:

C#
if (PreviousPage == "HomePage.aspx")
        {
            // certain code goes here
        }
        else if(PreviousPage == "SpecificPage.aspx")
        {
            // certain code goes here
        }


I hope you help me please like every time ;)
Thanks
Posted
Updated 17-Oct-10 16:56pm
v4
Comments
Brij 17-Oct-10 23:24pm    
You can get the previus page by Request.UrlReferrer.LocalPath property. What else you are looking for?
MrLonely_2 18-Oct-10 3:31am    
Thank you Mr.Revision 4

1 solution

I guess you are looking for "Request.UrlReferrer.AbsoluteUri"

A blog post: http://codebetter.com/blogs/peter.van.ooijen/archive/2005/07/19/129384.aspx[^]
 
Share this answer
 
Comments
MrLonely_2 17-Oct-10 22:57pm    
no man, it is not what i need.
I modified my question to can understand me

Thanks
Karthik. A 17-Oct-10 23:16pm    
Did you try UrlReferer.AbsoluteUri? Because that will give you the page from where you came to the current page. So setting PreviousPage = Request.UrlReferrer.AbsoluteUri; will help you check the condition you have mentioned above ( == or indexOf(...)) and then take necessary action... give it a go and see.
Joy.com 17-Oct-10 23:18pm    
hey man, I think Karthik has already given you the answer.
MrLonely_2 17-Oct-10 23:25pm    
Thanks
Thanks7872 21-May-13 0:56am    
↑voted..!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900