asp.net - Cors doesnt solve cross origin requests -
i have trying build angular app using asp.net mvc web api.
when make $resource request web server (localhost) get
xmlhttprequest cannot load http://localhost:59636/api/studios. no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:44060' therefore not allowed access. response had http status code 401.
i read installing cors solve this. doesnt. have tried both enabling cors
config.enablecors(new enablecorsattribute("*", "*", "*"));
as using attribute
[enablecorsattribute("*", "*", "*")]
it working on ie
in webapiconfig.cs file should have:
config.enablecors();
in applicationoauthprovider.cs, in grantresourceownercredentials():
context.owincontext.response.headers.add("access-control-allow-origin", new[] { "http://localhost:44060" });
and on controller:
[enablecorsattribute("http://localhost:44060", "*", "*")]
Comments
Post a Comment