且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

预检的响应具有无效的HTTP状态代码400-ASPX

更新时间:2021-08-08 05:02:33

解决方案是将以下内容添加到Global.asax文件中

The solution was to add the following to the Global.asax file

protected void Application_BeginRequest()
{
    var context = HttpContext.Current;
    var response = context.Response;


    if (context.Request.HttpMethod == "OPTIONS")
    {
        response.AddHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
        response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
        response.End();
    }
}