score:0

in the asp.net core + react templates by microsoft, the layout is not handled in the back-end with asp but in the front-end with react. in the clientapp/src/components folder, you will find a layout.js file for this usage.

however, nothing stops you to create a partial view _layout.cs and use razor pages / mvc as a react overlay. this way, every page should be handled with an asp controller. inside them you would add an empty html tag to place your react app if you need it.

in the clientapp/src/index.js file, you will find the following line:

const rootelement = document.getelementbyid('root');

you need to replace the element id by the one where you want to render your react application in the dom.


but typically, when using asp with react, the front-end is left entierly to react. asp is only useful for api controllers handling ajax requests coming from react, and interacting with a database using entity framework.


Related Query

More Query from same tag