其他分享
首页 > 其他分享> > HttpResponseMessage 返回支持跨域

HttpResponseMessage 返回支持跨域

作者:互联网

HttpResponseMessage response = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(new { code = 0, msg = "Hello World" }), Encoding.GetEncoding("UTF-8"), "application/json") };

response.Headers.Add("Access-Control-Allow-Origin", "*");

response.Headers.Add("Access-Control-Allow-Headers", "*");

return response;

标签:返回,跨域,HttpResponseMessage,Headers,Add,Allow,new,response
来源: https://www.cnblogs.com/SimpleTian/p/16257926.html