In my MVC controller, I have two methods with the same action name but with different routing attributes so they respond differently to GET and POST requests (modeled by this link):
[HttpGet] public string Test() { return "get"; } [ActionName("Test")] [HttpPost] public string Test_Post() { return "post"; } and the corresponding URI is just Sample/Test. I've also enabled attribute routing with routes.MapMvcAttributeRoutes() in my RouteConfig.cs.
However, if I send a GET or POST request to this URI, it always calls Test(), never Test_Post(). Why are the requests routed to the same method and ignoring the route attributes?
EDIT: To clarify, I send the request with an AJAX call:
$.post("https://{baseURL}/Sample/Test", function(result){ console.log(result); }}); which always prints "get" via Test() instead of "post" via Test_Post().