C# Razor pages - how do I use the @{_Layout.cshtml} website correctly on more than one page?

Asked

Viewed 15 times

0

Opá personal, good afternoon!

I’m starting a Razor Pages MVC project in Visual Studio, but I’m having a problem where I can’t index more than one page to the main layout

    @page
@{
    Layout = " _Login.cshtml";
}
    <form method="post" for="name email alias password confirm">
        <input type="text" value="name" name="name" />
        <input type="email" value="email" name="email"/>
        <input type="text" value="alias" name="alias"/>
        <input type="password" name="password" />
        <input type="password"name="confirm" />
        <input type="submit" value="Cadastrar" />
    </form>

What happens is that the createNewAcc.cshtml page does not load the body from the _Login.cshtml page

the code of the _Login.cshtml page is the one with the link to create a new account:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - SuporteTecnico</title>
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/site.css" />
</head>
<body>
    <header>
        <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
            <div class="container">
                <a class="navbar-brand" asp-area="" asp-page="/Index">Suporte Tecnico</a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
                        aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
                    <ul class="navbar-nav flex-grow-1">
                        <li class="nav-item">
                            <a class="nav-link text-dark" href="_Login.cshtml">Home</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link text-dark" href="createNewAcc.cshtml" >Criar Nova Conta</a>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
    </header>
    <div class="container">
        <main role="main" class="pb-3">
            @RenderBody();

        </main>
    </div>

    <footer class="border-top footer text-muted">
        <div class="container">
            &copy; 2021 - SuporteTecnico - <a href="createNewAcc.cshtml">Privacy</a>
        </div>
    </footer>

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>

    @RenderSection("Scripts", required: false)
</body>
</html>

Obs: it is already loaded in the page Index.cshtml, below image of the model: obs: ela já é carregada na página Index.cshtml, segue abaixo imagem da model:

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.