HTTP Error 405.0 - Method not allowed error in asp.net mvc 4 post method

1.2k views Asked by At

I have an existing asp.net mvc 4 solution. It has several controllers/models/views in separate folders and all work fine with both GET and POST controller methods. I have added a new folder and added its own controllers/models/views. When I call the GET controller method, from the view it works fine. But the POST controller method throws

HTTP Error 405.0 - Method not allowed. The page you are looking for cannot be displayed because an invalid method (HHTP verb) is being used.

The following is my view and controller

<div id="usercreds" class="items">
   @using (Html.BeginForm("SaveCustomer", "NewCustomer"))
   {
        //form control code here               
   }

   [HttpPost]
   public ActionResult SaveCustomer(NewCustomerModel newCustomer)
   {
        //more code here
   }

I added FormMethod.Post in the Html.BeginForm method and added modules="IsapiModule" in web.config file

I still get the same error.

1

There are 1 answers

0
Massey On BEST ANSWER

The issue was there were two identically named folders within the VisualStudio solution. Because of this it was posting to the wrong URL. I renamed one of the folders and it worked fine.