My _Layout.cshtml file is not being recognized in the application, what to do?

0

I'm doing an application in MVC asp.net, and out of nowhere my application no longer recognizes the layout file no longer applying the bootstrap and jquery ... How can I solve this ??

My layout file looks like this:

    <!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - Aplicação Teste</title>

    <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

</head>
<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                @Html.ActionLink("Nome do aplicativo", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">

                    @if (HttpContext.Current.User.IsInRole("Admin"))
                    {
                        <li>@Html.ActionLink("Início", "Index", "Home")</li>
                        <li>@Html.ActionLink("Relatorios", "Relatorios", "Home")</li>
                        <li>@Html.ActionLink("Cadastros", "Cadastros", "Home")</li>
                        <li>@Html.ActionLink("Contato", "Contatos", "Home")</li>
                    }

                    @if (HttpContext.Current.User.IsInRole("Premium"))
                    {
                        <li>@Html.ActionLink("Início", "Index", "Home")</li>
                        <li>@Html.ActionLink("Sobre", "About", "Home")</li>
                        <li>@Html.ActionLink("Contato", "Contatos", "Home")</li>
                    }
                    else
                    {
                        <li>@Html.ActionLink("Sobre", "About", "Home")</li>

                    }

                </ul>
                @Html.Partial("_LoginPartial")
            </div>
        </div>
    </div>
    <div class="container body-content">
        @RenderBody()
        <hr />
        <footer>
            <p>&copy; @DateTime.Now.Year - Projeto Andrêy Ferraz</p>
        </footer>
    </div>
    @Scripts.Render("~/bundles/jquery-3.3.1.js")
    @Scripts.Render("~/bundles/bootstrap.js")
    @RenderSection("scripts", required: false)
</body>
</html>

When loading the page and pressing F12 the following errors appeared:

GET http://localhost:49866/bundles/jquery-3.3.1.js net::ERR_ABORTED
GET http://localhost:49866/bundles/bootstrap.js net::ERR_ABORTED
GET http://localhost:49866/bundles/jquery-3.3.1.js net::ERR_ABORTED
GET http://localhost:49866/bundles/bootstrap.js 404 (Not Found)
    
asked by anonymous 26.01.2018 / 11:04

1 answer

2

To use the bundle, do not just add the path in your MasterPage (_Layout.cstml) you need to add your mapping in BundleConfig

And here, you should not call the specific script, but rather your bundle:

@Scripts.Render("~/bundles/jquery-3.3.1.js")
@Scripts.Render("~/bundles/bootstrap.js")

Probably the correct one would be:

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
  

I look forward to the post of your BundleConfig to improve the answer.

    
26.01.2018 / 18:30