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

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -