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
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>© @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")
On your pc it works but on the web it doesn’t work?
– viana
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.
– hard123
Check if you are linking correctly?
– viana
The site loads in Rowse, but the site does not find the bootstrap files and jquery is what you are asking ?
– hard123
Post the contents of the archive
Bundle.cs
– Jéf Bueno
@jbueno I added the Bundle file to the question, locally it works.
– hard123
Open your browser devtools - by pressing
F12
- go to the Network tab and see which requests are in red. Especially those with code404
that will be the ones not found.– Thiago Lunardi
@Thiago Lunardi added an image of navigating the error is the 403
– hard123
@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
@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
– hard123
@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.
– Leonardo Coelho
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 ofLogin
the system finds the files of Bootstrap and Jquery, the problem is after the user login which is redirected to aArea/Administrativo/Home
.– hard123
@Adrianosuv you use some view to create the Basic Layout? If yes, could post here the part where you render the Bundles?
– Leonardo Coelho
Yes @Leonardo Coelho , added in question.
– hard123
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"/>
– Leonardo Coelho
Check that the files are part of the project.
– Diego Vieira
You can access these files by browsing the URL?
– PauloHDSousa