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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -