How to do it...

We'll create two separate application projects, and from one of them we'll make a request to other. The other project is an ASP.NET Core project, and we'll enable/configure CORS in it:

  1. First, let's create the Web API application, by creating an empty web application:
    dotnet new mvc -n Chapter11.R3.Server
  1. Next, we will add the ASP.NET Core MVC dependency to the project:
"Microsoft.AspNetCore.MVC": "2.0.0"
  1. Next, let's add the following code to Startup.cs. This code allows us to use Web API's controllers:
public void ConfigureServices(IServiceCollection services){  services.AddMVC();}public void Configure(IApplicationBuilder app){  app.UseMVC();}
  1. Next, let's add the CORS middleware to the ASP.NET Core pipeline, and let's ...

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.