Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get previous page URL after Response.Redirect

I'm trying to get the previous page URL after I do a response write and i've looked around the web and people are using HTTP_REFERER but that doesn't work with Response.Redirect so is there anyway to get the URL of the previous page?

I have this code on a few pages and i need to know which page it is coming from when it gets to the servererror/default.aspx page

 Response.Redirect("servererror/default.aspx?404")

And on my servererror/default.aspx page i'm just trying to grab the previous page URL and put it into the Session Session("ErrorPage")

Thanks

Jamie

UPDATE

I have now got it to work like this

Response.Redirect("server-error.aspx?404&" & Request.Url.ToString())

That passes the URL of the page with the error to the next page and I then grab that from the Query String

Thanks

Jamie

like image 532
Jamie Taylor Avatar asked Dec 17 '22 21:12

Jamie Taylor


1 Answers

You can pass the URL of the previous page to the error page's URL. something like

Response.Redirect("servererror/default.aspx?404&url=/folder/page.aspx")

And then get the url value on the error page and redirect it to the previous page.

like image 55
rauts Avatar answered Jan 08 '23 00:01

rauts