My site does not find the Bootstrap and Jquery files

Asked

Viewed 839 times

5

I created a website ASP.NET MVC with Code First and did the first publish of the application, the Database and the Site were created, the problem is that the site does not find the files css and Jquery of Bootstrap and the Scripts folder.

I imagined that in the first publication of the site already contemplated the transfer of these files css and JavaScript of Bootstrap and the Scripts folder automatically.

I’m looking here in Azure where the root folder with compiled files is and I can’t find.

Bundleconfig.Cs file

public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/numeral").Include(
                 "~/Scripts/numeral/numeral.min.js"));

        bundles.Add(new ScriptBundle("~/bundles/moneymask").Include(
                  "~/Scripts/jquery.moneymask.js"));

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js",
                    "~/Scripts/jquery.maskedinput.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.validate*"));

        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                  "~/Scripts/bootstrap.js",
                  "~/Scripts/respond.js"));

        bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/site.css",
                  "~/Content/jquery-ui.css",
                  "~/Content/DataTables-1.10.12/media/css/jquery.dataTables.min.css",
                  "~/Content/DataTables-1.10.12/extensions/TableTools/css/dataTables.tableTools.min.css",
                  "~/Content/DataTables/css/jquery.dataTables.min.css"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                    "~/Scripts/jquery-ui-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/inputmask").Include(
                    "~/Scripts/jquery.inputmask/inputmask.js",
                    "~/Scripts/jquery.inputmask/jquery.inputmask.js",
                    "~/Scripts/jquery.inputmask/inputmask.extensions.js",
                    "~/Scripts/jquery.inputmask/inputmask.date.extensions.js",
                    "~/Scripts/jquery.inputmask/inputmask.numeric.extensions.js"));

        bundles.Add(new ScriptBundle("~/bundles/DataTables").Include(
       "~/Scripts/DataTables-1.10.12/media/js/jquery.dataTables.min.js",
       "~/Scripts/DataTables-1.10.12/media/js/dataTables.bootstrap.min.js",
       "~/Scripts/DataTables-1.10.12/extensions/AutoFill/js/dataTables.autoFill.min.js",
       "~/Scripts/DataTables-1.10.12/extensions/AutoFill/js/autoFill.bootstrap.min.js",
       "~/Content/DataTables-1.10.12/extensions/TableTools/js/dataTables.tableTools.min.js",
       "~/Scripts/DataTables/jquery.dataTables.min.js"));
    }

Error 403 occurs Forbiden

inserir a descrição da imagem aqui

This is the Layout file

Note: Stays in the folder

\Administrative Areas Views Shared_administrativolayout.cshtml

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - Administração</title>
    @Styles.Render("~/Content/css")

</head>
<body>
    <div class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
            </div>
            <div class="navbar-collapse collapse">
                <div class="navbar-header"></div>
                @Html.Partial("_MenuPartial")
            </div>
        </div>
    </div>
    <div class="container body-content">
        <div class="panel-heading">
            @RenderBody()
        </div>
        <footer>
            <p>&copy; @DateTime.Now.Year</p>
        </footer>
    </div>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

For a View that is located in:

\Areas Administrative Views Client

I do so:

@{
    ViewBag.Title = "CLIENTE";
    Layout = "~/Areas/Administrativo/Views/Shared/_AdministrativoLayout.cshtml";
}

Running the project works perfectly, but when I deploy the application does not find the jquery, css and bootstrap files and , as you can see I refer the Bundle file so: @Styles.Render("~/Content/css")

  • 1

    On your pc it works but on the web it doesn’t work?

  • Yes on my pc works and I just found the root directory on Azure and all the Bootstrap and Jquery files are there but it doesn’t work.

  • Check if you are linking correctly?

  • The site loads in Rowse, but the site does not find the bootstrap files and jquery is what you are asking ?

  • Post the contents of the archive Bundle.cs

  • @jbueno I added the Bundle file to the question, locally it works.

  • Open your browser devtools - by pressing F12 - go to the Network tab and see which requests are in red. Especially those with code 404 that will be the ones not found.

  • @Thiago Lunardi added an image of navigating the error is the 403

  • @Adrianosuv pdoeria let me know if you use _Bootrstraplayour.basic? If so, are all references there? I had a problem exactly the same as yours, in the case when I used Script.Render I was passing by parameter ("~/Scripts") and in Bundle config was ("~/js") what caused this error.

  • @Leonardo Coelho where is this file ? I searched in my Solution and did not find and I believe that my project does not use this file

  • @Adrianosuv so you probably don’t even use it. It is usually in it that you define the Basic Layout of your site as navigation menu and footers that are fixed to the entire site. Somewhere you have to reference, try searching in your project for a "Rendersection" or "Render.Render Scripts" or something. You might find.

  • Yes @Leonardo Coelho I use the BundlesConfig.cs which is in the App_start folder that is the default for the projects and in the Views I refer this way @Styles.Render("~/Content/css"), however I have an observation: on the screen of Login the system finds the files of Bootstrap and Jquery, the problem is after the user login which is redirected to a Area/Administrativo/Home.

  • @Adrianosuv you use some view to create the Basic Layout? If yes, could post here the part where you render the Bundles?

  • Yes @Leonardo Coelho , added in question.

  • Two more questions, are you sure these files are added in the project? Another thing, try to change the Styles Render line and put this. <link href="@Styles.Url("~/Content/css")" rel="stylesheet"/>

  • 1

    Check that the files are part of the project.

  • You can access these files by browsing the URL?

Show 12 more comments

2 answers

0

I changed the name of Stylebundle of: bundles.Add(new StyleBundle("~/Content/css") for bundles.Add(new StyleBundle("~/Content/css/Admin") Thanks @Leonardo Coelho for the suggestions.

  • Um... superficial answer yet. Confirm me if the folder no longer existed ~/Content/css. You’ll see that was the conflict.

-2

I had the same problem also in my . NET Core project. While the project correctly points to the bootstrap.css file, the site uploaded to the server points to the address below:

https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css

Detail: the server where the site was hosted was on the UOL Host, which does not support this framework, however the . NET Core gives you self-sufficient deployment option. If anyone has ever faced similar problem, please comment. Thank you.

Browser other questions tagged

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