redirecting back to referrer page in asp.net

Reply

Join Date: Nov 2009
Posts: 1
Reputation: capiono is an unknown quantity at this point 
Solved Threads: 0
capiono capiono is offline Offline
Newbie Poster

redirecting back to referrer page in asp.net

 
0
  #1
Nov 2nd, 2009
I have a link on page 1 if clicked take u to page 2

and page 2 if u click okay it should take u back to page

but when I use this on page 2 to:

  1. ViewState["back"] = Request.UrlReferrer;
it returns null,

how do I fix this

on page 1:
  1. link_Click(Obj sender, EventArgs e)
  2. {
  3. Response.Redirect("page2.aspx?ID" + row.cells[10].text)
  4. }
Last edited by peter_budo; Nov 2nd, 2009 at 7:07 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 452
Reputation: Ramesh S will become famous soon enough Ramesh S will become famous soon enough 
Solved Threads: 82
Ramesh S Ramesh S is offline Offline
Posting Pro in Training
 
0
  #2
Nov 3rd, 2009
You need to to get the Request.UrlReferrer if(!IsPostBack) in the Page_Load event and store it in the viewstate if your page perform postbacks.

Sometimes the Request.UrlReferrer is null if you are using AJAX to call Response.Redirect.

The UrlReferrer is based on the value of HTTP_REFERER header that a browser should send. Sometimes internet anti virus programs such as Norton's Internet Security will strip the header. Therefore the Request.UrlReferrer will be empty.

Instead of believing the Request.UrlReferrer, send the current page name as query string to the other page. In the target page, store the value of the query string in ViewState.

Refer these links.
http://stackoverflow.com/questions/1...lreferrer-null
http://stackoverflow.com/questions/1...from-another-s
http://forums.asp.net/t/1101617.aspx
Reply With Quote Quick reply to this message  
Reply

Tags
asp.net, c#, redirect

Message:




Views: 975 | Replies: 1
Thread Tools Search this Thread



Tag cloud for asp.net, c#, redirect
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC