I Have Created A WebAPI In MVC That Code Is Working Fine Am Trying To Use That Get Method In Another Project Of MVC With JQuery Function Call When Am Calling The Method Am Getting The Error is
The origin 'http://localhost:3038' is not allowed
Jquery Code
$(document).ready(function () {
$.ajax({
type: "GET",
url: "http://localhost:63540/api/emp",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
for (var i = 0; i < data.d.length; i++) {
$("#tbDetails").append("<tr><td>" + data.d[i].E_id + "</td><td>" + data.d[i].E_name + "</td><td>" + data.d[i].Designation + "</td><td>" + data.d[i].DepartmentName + "</td><td>" + data.d[i].E_doj + "</td><td>" + data.d[i].EmpType + "</td></tr>");
}
},
error: function (result) {
alert("Error");
}
});
});
I Have Enabled cors for WebAPI in Like in WebApiConfig.cs file added config.EnableCors();
And In API I added
[EnableCors(origins: "http://localhost:63540", headers: "", methods: "")]
Even I Enabled CORS In API Am Getting Error,How can solve this?, Thanks.
[EnableCors(origins: "http://localhost:63540", headers: "*", methods: "*")]?