2016-08-06 17 views
2

diesen Fehler Got während versuchen, mein Controller-Methode aufzurufen (Controller-Name ist ProductsController):Aufruf Controller-Methode über Ajax reach "404 not found"

public ActionResult GetProducts() 
{ 
    return false; 
} 

Telefonvorwahl wie folgt aus:

$(document).ready(function() { 
     $.ajax({ 
      type: 'POST', 
      url: '@Url.Action("GetProducts", "ProductsController")', 
      dataType: 'json', 
      cache: false, 
      contentType: 'application/json; charset=utf­8', 
      data: JSON.stringify(""), 
    }) 

Konsole in Chrome sagt:

jquery-1.10.2.js: 8720 POST http : // localhost: 56408/ProductsCon Troller/GetProducts 404 (nicht gefunden)

Haben Sie eine Idee, was ist das Problem?

+1

Verwenden Sie einfach das Controller-Name-Präfix 'Products' anstelle von' ProductsController' – Nkosi

Antwort

1

den Namen der Steuerung Präfix Products anstelle von ProductsController

$(document).ready(function() { 
    $.ajax({ 
     type: 'POST', 
     url: '@Url.Action("GetProducts", "Products")', 
     dataType: 'json', 
     cache: false, 
     contentType: 'application/json; charset=utf­8', 
     data: JSON.stringify(""), 
}); 

Asp.Net-MVC eine Namenskonvention für die Regler verwendet.

+0

Vielen Dank! – Anamnian

Verwandte Themen