I saw lot of post regarding this, but i don’t seem to find the answer,
I am trying to call controller Get method though AJAX
JS
$(document).ready(function () {
$.ajax({
type: "GET",
url: "api/CookBooks/",
dataType: "xml",
success: function (data) {
$.each(data, function (key, val) {
debugger;
});
},
error: function (xhr, textStatus, errorThrown) {
debugger;
}
});
});
Controller
[HttpGet]
public static IEnumerable<DTO> GetLatest()
{
// ...
}
i am getting response error "he requested resource does not support http method ‘GET’"
Why is that?
2
Answers
Do you have other HttpGet method inside controller?
you can call your controller Get method like below
Make sure you have proper names of controller method and that names you used in this ajax call,
along with that, if you have apis then only you have to add api as prefix, but if your project is mvc type then no need of appending api prefix