跨域问题

------------恢复内容开始------------

.Net 跨域

修改Global,添加如下代码

protected void Application_BeginRequest()
{
  if (Request.Headers.AllKeys.Contains("Origin") && Request.HttpMethod == "OPTIONS")
  {
    Response.End();
  }
}

修改Web.config,在<system.webServer>节点下添加如下代码

<httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*"/>
        <add name="Access-Control-Allow-Headers" value="*"/>
        <add name="Access-Control-Allow-Methods" value="GET,PATCH, POST, PUT, DELETE, OPTIONS"/>
      </customHeaders>
</httpProtocol>

.Net Core3.1跨域

https://www.cnblogs.com/puzi0315/p/12197612.html

 

 

------------恢复内容结束------------

posted @ 2021-01-28 11:19  xwxwxw  阅读(197)  评论(0编辑  收藏  举报