Creating a net 6 based website project with asp net core and react typescrip


ASP.NET is a popular programming language used for building web applications. It provides a for developing dynamic websites and web . In this article, we will explore how to create a .NET 6 based website project ASP.NET Core and React TypeScript.

Setting up the

Before we start building our website project, we need to set up the development environment. Here are the steps to follow:

  1. Install .NET 6 SDK: Download and install the latest version of .NET 6 SDK from the official Microsoft website.
  2. Install Node.js: ASP.NET Core with React TypeScript requires Node.js to be . Download and install Node.js from the official website.
  3. Create a new ASP.NET Core project: Open a prompt or terminal and run the following command to create a new ASP.NET Core project:
dotnet new web -n MyWebsite

Adding React TypeScript to the Project

Now that we have created our ASP.NET Core project, let's add React TypeScript to it. Follow these steps:

  1. Install the React templates: Run the following command in the command prompt or terminal to install the React templates for ASP.NET Core:
dotnet new react
  1. Configure the project to use React TypeScript: Open the project in your preferred code and locate the Startup.cs file. Add the following code to the ConfigureServices method:
services.AddSpaStaticFiles( =>
    configuration.RootPath = "ClientApp/build";
  1. Update the Configure method: Locate the Configure method in the Startup.cs file and its contents with the following code:
app.UseSpa(spa =>
    spa.Options.SourcePath = "ClientApp";

    if (env.IsDevelopment())
        spa.UseReactDevelopmentServer(npmScript: "start");

Creating Pages and Components

Now that we have set up React TypeScript in our ASP.NET Core project, we can start creating pages and components. Here's an example of how to create a simple page:

  1. Create a new named Pages in the project's root directory.
  2. Create a new file named Index.cshtml inside the Pages folder.
  3. Add the following code to the Index.cshtml file:

Welcome to My Website!

Now, when you run your ASP.NET Core project, you should see the “Welcome to My Website!” message on the homepage.


In this article, we have learned how to create a .NET 6 based website project using ASP.NET Core and React TypeScript. We have set up the development environment, added React TypeScript to the project, and created a simple page. This is just the beginning, and there is a lot more you can do with ASP.NET and React TypeScript. Happy coding!

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents