作者:永欣慧娟766 | 来源:互联网 | 2023-09-01 15:28
///
/// 解决跨域问题
///
///
///
protected void Application_BeginRequest(object sender, EventArgs e)
{
System.Web.HttpApplication app = sender as System.Web.HttpApplication;
HttpResponse respOnse= app.Response;
//支持跨域
if (app.Request.HttpMethod == "OPTIONS")
{
//支持跨域
response.AddHeader("Access-Control-Allow-Methods", "*");
response.AddHeader("Access-Control-Allow-Headers", "*");
response.AddHeader("Access-Control-Allow-Origin", "*");
response.AddHeader("Cache-Control", "no-cache");
response.StatusCode = 200;
response.End();
}
else
{
response.AddHeader("Access-Control-Allow-Origin", "*");
response.AddHeader("Access-Control-Allow-Headers", "*");
response.AddHeader("Access-Control-Allow-Methods", "*");
response.AddHeader("Cache-Control", "no-cache");
//response.AddHeader("Access-Control-Allow-Methods", "GET, POST,PUT, DELETE");
//response.AddHeader("Access-Control-Allow-Headers", "Content-Type");
}
}
每走一步都是对自我的一种提升,只要你努力了那么你就没有什么好遗憾的了,现在的我刚从起跑线站起来,我已经有向前跑的准备了,至于最后的结果已经不是我该关心的了,期望以后的自己越来越好,越来越优秀,加油,老许。