I have a requirement which needs me to redirect an user to previous page on his browsing history. I am using ASP.net MVC 1.0. I do NOT want to use javascript to achieve this. Any pointers?
3 Answers
You can use the Request.UrlReferrer property to render out a link. Maybe like this:
<a href="<%= Request.UrlReferrer %>">Back</a>
3 Comments
Bruno Reis
This will not work if the browser blocks the referrer... and many people seem to do that nowadays!
Darko
I've never had that problem to be honest - i guess the OP will have to decide whether this is a risk for his site though
Nathan
It's fairly common to block the referrer when you are behind a corporate firewall.
And what about:
<a class="ImageBtn" href="previous.html" onClick="history.back();return false;">Go back</a>
In this case you can asign an image so it looks better.
2 Comments
Ruskin
That is using javascript ... and adding an image will increase the page load ... better to implement prettiness using CSS.
eduardo cruz
in fact the idea is to use css in the "class" also did not notice the "NOT"