I have an ActionFilter attribute at the top of my controller.
[HandleError]
[MyActionFilter]
public class AccountController : Controller
{
...
}
When an action is received, i want to add/change some route values and then redirect to a correct route.
filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { lang = langName, controller = controllerName, action = actionName, id = idName }));
This is working fine. However, the redirection is always set to HTTP GET, and since some of my actions are set to receive only HTTP POST, it fails.
Is there any way to make the redirection be HTTP POST?
Is there any way to make the redirection be HTTP POST?
No. The verb GET is at the very base of the definition of a redirect in the HTTP specification. It simply doesn't make sense to talk about an HTTP redirect and an HTTP verb different than GET.
Instead of redirecting you could return a view directly:
var result = new ViewResult
{
ViewName = "~/Views/Shared/SomeView.cshtml",
};
result.Model = new MyViewModel();
filterContext.Result = result;