摘自
引用System.Web.Http.Cors
在一下类型中可添加[EnableCors(XXXX)]
- Action
- Controller
- 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
}