We have an MVC 5.1 project and we use attribute routing. Everything works fine except for the default page, which has a login form.
[RoutePrefix("Home")]
public class HomeController : BaseController
{
[Route("~/")]
[Route]
[Route("Index")]
[HttpGet]
public ActionResult Index()
{
var model = new LoginViewModel();
return View(model);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Index(String Username, String Password)
The form is displayed via GET, but after POST we get ...
HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because it uses an invalid method (HTTP verb).
Typically, the default route will handle both POST and GET.
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}/{dealerId}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Obviously, I am missing something here in the routing for the message on the default route, since subsequent messages on other pages work fine.
Has anyone done this?
Thanks,