405 angular js posting to web service (firefox)
The following code works fine using internet explorer and receives a 200 response. However, using Firefox generates a 405. When using fiddler I can see that IE passes the json object but firefox doesn't.
app.service('UserService', function ($http) {
this.GetLoginStatus = function (AuthenticateRequest) {
$http.defaults.useXDomain = true;
$http({
url: APIURL + '/Authenticate',
method: "POST",
options: {},
data: AuthenticateRequest,
headers: {'Content-Type': 'application/json'}
}).success(function (data, status, headers, config) {
console.log(data);
console.log(status);
console.log(headers);
console.log(config);
}).error(function (data, status, headers, config) {
console.log(data);
console.log(status);
console.log(headers);
console.log(config);
});
};
});
Fiddler inspection FireFox OPTIONS http://www.myapi.com:56586/V1/Service.svc/json/Authenticate HTTP/1.1 Host: localhost:56586 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Origin: http://www.myapi.com:54567 Access-Control-Request-Method: POST Access-Control-Request-Headers: content-type,x-requested-with Connection: keep-alive Pragma: no-cache Cache-Control: no-cache
IE POST http://www.myapi.com:56586/V1/Service.svc/json/Authenticate HTTP/1.1 X-Requested-With: XMLHttpRequest Accept: application/json, text/plain, / Content-Type: application/json Referer: http://www.myapi.com:54567/ Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko Host: localhost:56586 Content-Length: 45 DNT: 1 Connection: Keep-Alive Pragma: no-cache
{"UserName":"username","Password":"password"}
链接地址: http://www.djcxy.com/p/46246.html