I have created Web API(CRUD operation) and deploy into local IIS server and consuming through jquery create and read is working fine but facing problem during Update and Delete server throwing 405 method not allowed
<script type="text/javascript">
function UpdatePerson() {
var PersonId =$("#PersonId").val();
var city = $("#CityId").val();
var name = $("#Name").val();
var EmailAddress = $("#EmailAddress").val();
var Password = $("#Password").val();
var Gender = $("#Gender").val();
var BirthDate = $("#BirthDate").val();
var person = new Object();
person.CityId = city;
person.Name = name;
person.EmailAddress = EmailAddress;
person.Password = Password;
person.Gender = Gender;
person.BirthDate = BirthDate;
$.ajax({
type: "PUT",
url: "http://localhost/api/restapi/"+PersonId,
data: JSON.stringify(person),
contentType: "application/json; charset=utf-8",
dataType: "json",
processData: true,
success: function (data, status, jqXHR) {
alert(" record updated successfully … ");//data - response from server
},
error: function (xhr) {
alert(xhr.responseText);
}
});
}
</script>
Resolving HTTP 405 Errors
There are several reasons why a specific HTTP verb may not be allowed, but there is one primary scenario that is the leading cause of this error in IIS: multiple handlers are defined for the same verb/method, and one of the handlers is blocking the expected handler from processing the request. By way of explanation, IIS processes handlers from first to last based on the order handler entries in the applicationHost.config and web.config files, where the first matching combination of path, verb, resource, etc., will be used to handle the request.
but i could not find out which handler is blocking PUT and DELETE Method how to resolve this issue ?