skip to Main Content

I am using Visual Studio template called "React with ASP.NET Core". This template has 2 different projects, one for backend which includes ASP.NET Core Web API controllers etc., and the other client side stuff such as react.

When I run or debug project, it takes me to home controller. But actual interface of my home page which I created in react runs with npm command on localhost:3000. When I try to publish this project on Azure, it shows project has published successfully but when site opens, it says page not found with http 404 error.

I have another question: will the index.html be the entry point of the published project automatically? Since I open it through npm-start command? Do I need to publish them separately?

I can see in solution of this template the project reference of clientApp project has attached to backend project. And when publishing, npm build command is run.

2

Answers


  1. The 404 error might be due to incorrect configurations or missing files.
    In a typical React application, index.html is the entry point. However, in a mixed ASP.NET Core and React application, the entry point might depend on your project configurations but most of the time it is index.html.
    Yes, if your React and ASP.NET Core projects are separate, you may need to publish them separately. also make sure that the React app’s static files are correctly included in the ASP.NET Core project.

    Hope this helps

    Login or Signup to reply.
  2. If you open the properties of "solution" , you could find it is multiple startup. So when you run debug, it will start both 2 projects.
    enter image description here
    But when you publish, what you have published is only the server project. It doesn’t have any front-end page.
    enter image description here
    So what you need is publish the react client project to Azure seperately. And change the api proxy URL configuration in vite.config.js file.
    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search