摘自

https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/enabling-cross-origin-requests-in-web-api

 

引用System.Web.Http.Cors

在一下类型中可添加[EnableCors(XXXX)]

  1. Action
  2. Controller
  3. Global

测试:

c#

var xhr = new XMLHttpRequest();
xhr.open('get', 'http://www.example.com/api/test');
xhr.withCredentials = true;

 

jquery:

$.ajax({
type: 'get',
url: 'http://www.example.com/api/test',
xhrFields: {
withCredentials: true
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-03-30
猜你喜欢
  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2021-10-16
相关资源
相似解决方案