Why is my ASP.NET Web API route working with Postman but not working with Angular Post request

前端 未结 2 1433
半阙折子戏
半阙折子戏 2021-01-20 23:13

I have no idea what\'s going on here. I have a POST route using ASP.NET web API that should change some data in my SQL Server. When I use Postman to test out my REST API it work

2条回答
  •  轮回少年
    2021-01-20 23:43

    In Global.asax.cs file add following code

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

提交回复
热议问题