L
L
lucky42020-12-17 20:33:05
ASP.NET
lucky4, 2020-12-17 20:33:05

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>
}


My page was white. And then parallelly removed ReactConfig in App_Start and this folder itself. Idalil all deps and also climbed into web.config .... And as a result, I now have an error: "HTTP Error 403.14 - Forbidden".

Well, index should be rendered:
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 question

Ask a Question

731 491 924 answers to any question