React with ASP.NET Core
Publish a React front end together with an ASP.NET Core back end.
The React and ASP.NET Core template in Visual Studio creates a React front end and an ASP.NET Core back end in one solution. Both parts are published together to a single website — you only have to publish the right project.
Before you start
- A website created in the Control Panel — see Create your first website.
- Visual Studio with the ASP.NET and web development workload.
Create the project
Choose the template
In Visual Studio create a new project, select React and ASP.NET Core and click Next.
Finish the wizard
On the Additional information page leave the default settings and click Create.
The template creates two projects: a client project (React) and a server project (ASP.NET Core).
Important
Always build and publish the server project. It includes the client application in its output.
Publish
Download the publish profile
In the Control Panel open your website, choose Deploy, switch WebDeploy to Enabled on the Visual Studio access card and click Download publish profile. Save the
.publishSettingsfile.Build the server project
In Solution Explorer right-click the server project and choose Rebuild.
Import the profile
Right-click the server project again and choose Publish. Click Import profile and select the
.publishSettingsfile.Publish
Click Publish. Visual Studio publishes the application to your website.
When the publish finishes, open the website in your browser. The React application loads and calls the ASP.NET Core back end on the same address.
Something went wrong?
- Error 500 after publishing. See HTTP Error 500 – the application failed to start.
- The front end is on another domain than the API. See CORS errors when calling your API.