Reputation: 427
Got that error while try to call my controller's method (controller's name is ProductsController
):
public ActionResult GetProducts()
{
return false;
}
Calling code like this:
$(document).ready(function () {
$.ajax({
type: 'POST',
url: '@Url.Action("GetProducts", "ProductsController")',
dataType: 'json',
cache: false,
contentType: 'application/json; charset=utf8',
data: JSON.stringify(""),
})
Console in Chrome says:
jquery-1.10.2.js:8720 POST http ://localhost:56408/ProductsController/GetProducts 404 (Not Found)
Do you have any idea what is the problem?
Upvotes: 2
Views: 2767
Reputation: 247123
Use the controller name prefix Products
instead of ProductsController
$(document).ready(function () {
$.ajax({
type: 'POST',
url: '@Url.Action("GetProducts", "Products")',
dataType: 'json',
cache: false,
contentType: 'application/json; charset=utf8',
data: JSON.stringify(""),
});
Asp.Net-MVC uses a naming convention for controllers.
Upvotes: 2