asp.net - The requested resource does not support http method 'GET' when doing cross-domain ajax call -
i'm performing cross-domain post using jquery ajax call asp.net 4.5 webapi site:
$.support.cors = true; $.ajax("http://mydomain/webapi/api/authentication/", { type: "post", data: json, contenttype: "application/json" });
here server method:
public class authenticationcontroller : apicontroller { // login or logout user. // post api/authentication login or logout data object public httpresponsemessage post(object data) { return processaction(data); } }
i've set headers on remote server:
access-control-allow-origin: *
access-control-allow-methods: post,get, options
when execute code, 405 method not allowed - requested resource not support http method 'get'.
the method calling works fine if called same domain.
additionally, if remove contenttype: "application/json"
option, 500 server error.
it appears contenttype option has problem, not sure.
any suggestions or advice appreciated!
thanks.
Comments
Post a Comment