if (Request.Headers.Get ("Origin") = null) {
FilterContext.HttpContext.Response.AddHeader ("Access-control-allow-origin", Request.Headers.Get ("Origin"));
FilterContext.HttpContext.Response.AddHeader ("Access-control-allow-credentials", "true");
}
Add two headers The first Origin represents a host that allows cross-domain access
The second setting of ture means that cookie forwarding is allowed
$.ajax ({url: ' Http://localhost:5501/user/login?userinput=13068852262&pwd=xuelei ', Xhrfields: {
Withcredentials:true
},success:function (data) {Console.log (data)}})
Xhrfields Property Withcredentials set to True to set cookie forwarding
If you do not need to forward the cookie this item can not set the second item in the header or set
{readystate:1, getResponseHeader:?, getAllResponseHeaders:?, setRequestHeader:?, Overridemimetype:?, ...}
Vm5932:3 {
"State": "Success",
"Content": "OK",
"Total": 0
}
HTTP cross-domain access