Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8901

MVC POST is 404ing but if I change the POST to a GET, it works

$
0
0
I have an MVC 4 application running on Kentico 11. I'm trying to make a new API endpoint for a node application to be able to hit it. The method is structured as follow: [Route("api/SendEmail/projectEmail"), HttpPost] [EnableCors(origins: "http://localhost:3000", headers: "*", methods: "*")] public JsonResult KioskEmailSubscribe(KioskEmailModel emailModel) { // code that doesn't matter because we don't get this far } Whenever I use Postman to make a POST to this endpoint, it 404s. However, when I change the HttpPost to a GET (and remove the emailModel), it goes through just fine. I tried changing it back to a POST (still without the emailModel) and it still 404s. There's nothing fishy in my routeConfig as far as I know but I've attached it just to be safe:public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.LowercaseUrls = true; routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("cms/{*pathinfo}"); routes.Kentico().MapRoutes(); routes.MapMvcAttributeRoutes(); // Catch-all routes (Anything not matching a specific route pattern will route to the default controller and be determined there) routes.MapRoute("Default", "{*route}", new { controller = "Default", action = "Index" }); } }

Viewing all articles
Browse latest Browse all 8901

Trending Articles