I try to make a PUT request on JQUERY to a RESTFULL service, when try make the request to url with localhost (http://localhost/Domain) the request work. But when change the url to some ip (http://192.123.32.3) the operation on the server don't fire.
$.ajax({
type: "PUT",
url: urlOperation,
dataType: "json",
contentType: "application/json",
data: $.toJSON(submitVote), success: function (result)
{
alert('Great ...');
}
});
The error on chrome are 'Method PUT is not allowed by Access-Control-Allow-Methods'
I've try solve this adding the put permission on Application_beginRequest event something like that :
private void EnableCrossDmainAjaxCall()
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}
}
After read the jquery.Ajax documention I've try added the property crossDomain='true' without sucess.
Thanks and Regards