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

Asked

Viewed 321 times

0

I’m making an application in MVC Asp.net, and suddenly my application no longer recognizes the layout file being no longer applying the bootstrap and jquery... How can I fix it??

My layout file is 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>

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

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)
  • Have you checked the library paths? Check your question, you are confused.

  • Confused, I didn’t understand... look, I will edit the question and put the code of how my layout is... it seems that after I update the Jquery and bootstrap libraries!!

  • What do you mean "don’t recognize"?

  • @LINQ when I run the application it does not load the correct renderings of bootstrap and jquery, that is, the page is as if there is no CSS in it, all disfigured!!

  • Checks if you are displaying an error message while loading the page. Press F12.

  • @Emanuelf will edit the question and put the error that appeared

  • You changed the path to this new version of jquery in the file Bundle?

  • 1

    Check out that Article: https://msdn.microsoft.com/pt-br/library/dn168847.aspx

  • I read and did not help in much, because apparently everything is ok

  • put on your Bundleconfig

Show 5 more comments

1 answer

1


To use Bundle, simply add the path to your MasterPage (_Layout.cstml) you need to add your mapping in BundleConfig

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

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

Probably the right thing to do:

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

I’m waiting for your Bundleconfig post to improve the answer.

  • As incredible as it looks alone it’s back to normal, it was probably a problem in the IIES and not in the application itself, now it’s working normal!!!

Browser other questions tagged

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