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?
+1
A:
You can take a parameter "returnUrl" in your action, and then return a RedirectResult. It should do.
For info, take a look at the Account controller, from the default template ASP.NET MVC project on VS2008.
Bruno Reis
2009-08-24 22:38:19
this will only work for pages within his site.
Darko Z
2009-08-24 22:49:43
+1
A:
You can use the Request.UrlReferrer
property to render out a link. Maybe like this:
<a href="<%= Request.UrlReferrer %>">Back</a>
Darko Z
2009-08-24 22:40:01
This will not work if the browser blocks the referrer... and many people seem to do that nowadays!
Bruno Reis
2009-08-24 22:41:02
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
Darko Z
2009-08-24 22:42:55
It's fairly common to block the referrer when you are behind a corporate firewall.
Nathan
2009-08-24 22:44:13