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

maybe helps? calling default api/values

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

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -