asp.net - Server application has enabled CORS yet client gets "Access-Control-Allow-Origin" error -
i have restful api
, i've added allow cross-origin request
public static void register(httpconfiguration config) { ... // allow cross-origin request var cors = new enablecorsattribute("*", "*", "*"); config.enablecors(); ... }
my client angularjs
application calling server this
var json = json.stringify({ request: 'init' }), req = { method: 'get', url: 'http://localhost:51615/api/call/2/' + json } $http(req) .then(function(response){ console.info('response', response) }) .catch(function(error){ console.error(error); })
even thou cross-origin should allowed still error
xmlhttprequest cannot load http://localhost:51615/api/call/2/%7b%22request%22:%22init%22%7d. no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:86' therefore not allowed access. response had http status code 400.
how can be?
big @shaunhusain pointing out should take @ network response in chrome
. here saw problem unsafe data in url string (the json part). changing request get
post
along json data , not part of url fixed problem
Comments
Post a Comment