views:

691

answers:

3

How do I get the referrer URL in an ASP.NET MVC action? I am trying to redirect back to the page before you called an action.

+2  A: 
Request.ServerVariables["http_referer"]

Should do,

Dan

Daniel Elliott
Thanks, though you're missing an 's' on ServerVariables :)
Nat Ryall
Edited, cheers!
Daniel Elliott
+3  A: 

You can use Request.UrlReferrer to get the referring URL as well if you don't like accessing the Request.ServerVariables dictionary directly.

Derek Lawless
+2  A: 

Bear in mind that not all user-agents (AKA browsers) will send the referrer information, and some may even fake it.

belugabob
I am aware of this but thanks for mentioning it.
Nat Ryall