jquery - angularjs - Request header field is not allowed by Access-Control-Allow-Headers in preflight response -


i'm using lib https://github.com/doedje/jquery.soap/ connect ionic app asmx webservice. however, i'm getting error:

xmlhttprequest cannot load http://10.10.9.169/userservice3/webservice1.asmxgetuserbyusername. request header field soapaction not allowed access-control-allow-headers in preflight response. jquery.soap.js:456 uncaught error: unexpected content: undefined

here's controller.js code:

$scope.enterlogin = function(usern,pass) {     $.soap({         url: 'http://<webservice's ip address>/userservice3/webservice1.asmx',         method: 'getuserbyusername',          data: {             uname: usern,             passw: pass         },          success: function (soapresponse) {             console.log('response = ' + soapresponse);         },          error: function (soapresponse) {             // show error             console.log('response error = ' + soapresponse);         }      }); } 

i've added following in webservice's web.config file:

<webservices>   <protocols>     <add name="httpget"/>     <add name="httppost"/>   </protocols> </webservices> <httphandlers>     <add verb="get,head,post,options" path="*.asmx" type="system.web.ui.webservicehandlerfactory" /> </httphandlers>  <httpprotocol>     <customheaders>         <add name="access-control-allow-origin" value="*" />         <add name="access-control-allow-headers" value="content-type, authorization" />         <add name="access-control-allow-methods" value="get, post, put, delete, options" />     </customheaders> </httpprotocol> 

am missing something?

the error message seems indicate request includes header name soapaction.

so seems need add header name following part of web.config file:

<add name="access-control-allow-headers"      value="soapaction, content-type, authorization" /> 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -