简体   繁体   中英

CORS in .net Core application isn't working

I have .Net Core application with angular 2 cli. I am trying to call my controller action from the different port, I know that I can use CORS to make that work, but it is not working. has anyone the idea what could be the problem? thank you!

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

Your current configuration is allowing the wrong origin (HTTPS and not HTTP).

//Optional - called before the Configure method by the runtime
public void ConfigureServices(IServiceCollection services)
{
    services.AddCors();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{    
    app.UseCors(builder =>
       {
           builder.WithOrigins("http://localhost:4200")
           .AllowAnyMethod()
           .AllowAnyHeader();
       });
   )
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM