c# - Cross-Origin Requests WebApi -


i reading https://docs.microsoft.com/en-us/aspnet.... security prevent ajax requests domain , makes me wonder, if enable this, able make request android client? cu'z seems outside of domain, can't requested. it? thanks!

would like:

context.owincontext.response.headers.add("access-control-allow-origin", new[] { "*" });         using (iuserrepository _repository = new userrepository(new data.datacontexts.oauthserverdatacontext()))         {             var user = _repository.authenticate(context.username, context.password);              if (user == null)             {                 context.seterror("invalid_grant", "the user name or password incorrect.");                 return;             }         } 

if making request domain need set access-control-allow-origin header. can use * if aren't concerned security it's best specify domains know need access.

non-browser-based clients may not send origin header (e.g. postman) in case won't need worry setting cors.

that documentation linked start. this post provides basic example if want set access globally rather per-controller basis.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -