404 error while trying to call asp.net web api using jQuery AJAX -
I tried to create a simple asp.net web API and tried to use it in jQuery. But it throws a 404 error. Here is the web API code.
Public Class Product Controller: API Controller {[http Post) Public Product GetProductDetail () {Product Product = New Product (); Product.ProductName = "Cricket bat"; Product.ProductPrice = "100"; Return product; }}
And here is the jQuery Ajax code:
$ (function () {$ .ajax ({type: 'GET', url: 'Controllers / Product Controller / GateProud Dipet', success: function (success) {console.log (success);}, error: function (error) {console.log (error);}});});
System.Web.Http Please try .vc
public class ProductController: ApiController {[System.Web.Http.HttpGet] [System.Web.Http.AcceptVerbs ("GET", "POST")] PublicProductDetail () {Product product = new product (); Product.ProductName = "Cricket bat"; Product.ProductPrice = "100"; Return product; }}
Then change your Ajax URL to "/ Products / GetPrint Dictate"
Comments
Post a Comment