我可以从POSTMAN中点击这个方法但是无法从简单的html页面点击以下是代码示例:
Jquery代码
var certificateNumber = $("#txtCertificateNumber").val();
$("#search-Certificate").click(function() {
$.ajax({
type: "GET",
url: "http://localhost:8073/api/ami/CertificateDetails",
data: certificateNumber,
contentType: "application/json; charset=utf-8",
cache: false,
success: function(data) {
$("#resultarea").text(data);
}
});
});
控制器API代码
[RoutePrefix("api/ami")]
[EnableCors(origins: "*", headers: "*", methods: "*")]
public class APIController: ApiController {
[HttpGet]
[Route("CertificateDetails/{certificateNumber}")]
public HttpResponseMessage GetHatcheryCertificateBy(string certificateNumber) {
}
}