Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the referrer URL in an ASP.NET MVC action?

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.

like image 276
Ryall Avatar asked Sep 24 '09 11:09

Ryall


People also ask

How does MVC handle wrong URL?

First: Add a route pattern to the end of your routing table that matches to any URL. Second: Set the default controller and action values for this pattern to the controller/action method that will display the "more helpful" View you want to provide. (And, I guess, a third step: Provide that controller/action/View.)

Why is HTTP referer empty?

There might be several reasons why the referer URL would be blank. It will/may be empty when the enduser: entered the site URL in browser address bar itself. visited the site by a browser-maintained bookmark.


1 Answers

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

like image 192
derek lawless Avatar answered Oct 02 '22 17:10

derek lawless