关于跨域问题(包括端口和域名跨域)

  1、C#语言跨域 我估计任何语言在返回头加这个都可以解决跨域问题    

//完全跨域设置 包括跨域名和端口
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*"); //跨域名
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "*");//跨端口
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
//HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");允许的请求类型
var data = HttpContext.Current.Request.Form["data"].ToString();
HttpContext.Current.Response.ContentType = "text/plain";
HttpContext.Current.Response.Write(data);
View Code

相关文章: