wcf - Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘(null)’ in Angular 2 -
i have post service in wcf has object parameter shown below:
[operationcontract] [webinvoke(uritemplate = "placequestion", requestformat = webmessageformat.json, responseformat = webmessageformat.json, method = "post", bodystyle = webmessagebodystyle.bare)] string placequestion(questions question);
in web.config file, have add access-control:
<httpprotocol> <customheaders> <add name="access-control-allow-origin" value="*"/> </customheaders> </httpprotocol>
now in angular service tried call method follows:
var json = json.stringify({ type : 0, question: "testing" }); var url = 'http://localhost:49753/restserviceimpl.svc/placequestion'; var params = 'json=' + json; var headers = new headers(); headers.append('content-type', 'application/json'); return this._http.post(url, params, { headers: headers }) .map(res => res.json());
but when run program got error. btw, angular program running in localhost:4200.
cross-origin request blocked: same origin policy disallows reading remote resource @ http://localhost:49753/restserviceimpl.svc/placequestion. (reason: cors header ‘access-control-allow-origin’ not match ‘(null)’).
what seems problem?
Comments
Post a Comment