How do you enable cross-origin requests (CORS) in ASP.NET Core MVC

后端 未结 6 1807
广开言路
广开言路 2020-12-05 04:34

I\'d like to enable CORS on an API built with ASP.NET Core MVC, but all the current documents refer to earlier versions of that framework.

6条回答
  •  时光说笑
    2020-12-05 05:21

    cs1929 the method services.ConfigureCors(...) does no more exist. It is combined to AddCors:

    services.AddCors(options => 
        options.AddPolicy("AllowAllOrigins", builder => builder.AllowAnyOrigin()));
    

提交回复
热议问题