String origin = filterContext.HttpContext.Request.Headers["Origin"];
filterContext.HttpContext.Response.AppendHeader("Access-Control-Allow-Origin", "*");//设置允许跨域
filterContext.HttpContext.Response.AppendHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE");
filterContext.HttpContext.Response.AppendHeader("Access-Control-Max-Age", "3600");
filterContext.HttpContext.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");//设置允许跨域
filterContext.HttpContext.Response.AppendHeader("Access-Control-Allow-Credentials", "true");
原文地址:https://www.cnblogs.com/chuangli/p/12186528.html
时间: 2024-11-11 17:28:35