gruckion / learning

Learning stuff
0 stars 0 forks source link

ASP.Net Core 2.2 Razor with Node/Webpack/React #9

Closed gruckion closed 5 years ago

gruckion commented 6 years ago

Purpose instructions / research on how to create an ASP.Net Core 2.2 Razor which uses Node / Webpack for bundling and pulls through react / redux.

gruckion commented 6 years ago

Starting with ASP.NET Core 2.2 Web Application (MVC)

Creating the project

using dotnet cli

dotnet new razor -f netcoreapp2.2 -n AspNetCoreRazorReact -o AspNetCoreRazorReact

open with vscode code . and use dotnet run to start.

An excellent guide to setting up an ASP.Net Core project that uses node / webpack and uses the ASP.Net Core pipeline to call the webpack middleware.

gsearch: adding react to .net core razor Lean ASP.NET Core 2.1 – manually setup a Razor Pages project with Bootstrap, NPM and webpack

Then we can add React into the application

Lean ASP.NET Core 2.1 – add a React application to an existing Razor Pages application

gruckion commented 5 years ago

After completing the above and putting in redux and react-route. The application is able to handle routes such as clicking the about us page. However if you hit refresh this is then interpreted by the server and returns 404.

Solution: create the controller for a default root (home controller) that points to the index.cshtml

Handling HTML5 Client Route Fallbacks in ASP.NET Core .NET Core 2.1 React Create App CLI Bootstrap App Using MapWhen ASP.Net Core ASP.NET Core Middleware