Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return 307 Temporary Redirect in ASP.NET MVC

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

I sometimes need to re-POST the values submitted from one form to another URI.

Using JavaScript to do the selection on the client side (thereby bypassing this issue) is not an option.

Redirecting via a GET is not an option as posted data includes an 8k string which is likely to mean that the URI would be too long for some (many?) browsers.

Is this even possible?

like image 721
Matt Lacey Avatar asked Oct 29 '09 14:10

Matt Lacey


People also ask

How do I redirect to an action in ASP NET MVC?

RedirectToAction(String, String, RouteValueDictionary) Redirects to the specified action using the action name, controller name, and route values.


1 Answers

ASP.NET Core:

 public RedirectResult (string url, bool permanent, bool preserveMethod);

So

return Redirect(url, false, false); // 302
return Redirect(url, true, false);  // 301
return Redirect(url, false, true);  // 307
return Redirect(url, true, true);   // 308
like image 128
Sasan Avatar answered Sep 18 '22 20:09

Sasan