Answer the question
In order to leave comments, you need to log in
How to render a page?
Decided to learn ASP.NET. Everything was fine for the time being, until I decided to throw React into the project. At first I installed React via NuGet, then I decided to install the React folder in Scripts and then draw it in _Layout and Index:
<body>
//layout
<div id="root"></div>
@RenderSection("ReactApplication", required: false)
</body>
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Index</h2>
<div id="root"></div>
@section ReactApplication
{
<script src="~/Scripts/frontend/src/index.js"></script>
}
public ActionResult Index() {
IEnumerable<Product> products = database.Products;
ViewBag.Products = products;
return View();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question