Return 307 Temporary Redirects in ASP.NET MVC

Is it possible to return 307 Temporary Redirect from a controller to ASP.NET MVC?

I sometimes need to return POST values ​​submitted from one form to another URI.

Using JavaScript to select on the client side (thereby bypassing this problem) is not an option.

GET redirection is not an option, as published data includes an 8k string, which may mean that the URI will be too long for some (many?) Browsers.

Is it possible?

+6
redirect asp.net-mvc
source share
2 answers

Take a look at the following article - you can use the same technique for 307:

301 Redirects

+3
source share

To return the result of a 307 redirect from an MVC action, use the following:

 public ActionResult Action() { string url = GetRedirectUrl() HttpContext.Response.AddHeader("Location", url); return new HttpStatusCodeResult(307); } 
+7
source share

All Articles