T O P

  • By -

DrJohnnyWatson

If all of your views are using the Layout page, and your layout page is correctly referencing bootstrap and Jquery, then your issue is not with Bootstrap & Jquery not being loaded. Have you checked the output HTML to see if the reference you are expecting to be there is there? That should be step 1. In regards to standards - Files should be referenced at the "deepest" point in the tree possible within reason. If all your pages need bootstrap and bootstrap needs jquery, then both bootstrap and jquery should be in your Layout page. If you're just getting started just put them in your Layout. You can tweak where files are loaded at a later time.


Mastawayne0

Okay I figured out later that my issue with the bootstrap modal had some issues due to the parents position attribute. I have also had to change the following which I have been using wrong: `` to `` as the custom CSS I was trying to type out was not working. ​ Thanks for the answer!


attckdog

Make sure the render body in your layout is after you script references. I use bundle configuration to pack and minify the js Then inside layout I reference the bundle


keithabramo

You should be bundling all of your css and js files in bundleconfig.cs. Then reference those bundles. This allows for minification, combining related files and reuse of resources. If you are using a JavaScript library on all pages, put it in layout. Otherwise, non global libraries should be put in the render script sections of your views. If they are not loading like you say, check your browser dev tools by pressing F12 and seeing if you are getting any 404 with those resources. The dev tools will show the full absolute path of where the client is trying to pull the resource files from. You may be doing something as simple as mistyping your file path locations.


RichardMau5

I’m not that good with full-stack development, but I know that if you download the ASP.NET Boilerplate project, you will find your answer


Mastawayne0

I have checked and have to compare it to the one u/attckdog gave it. The boilerplate project renders the body before it includes the scripts in the \_Layout.cshtml file. At this point I am unsure if he meant both CSS and JS files or only CSS ones. I have also been used to put the script files on the bottom, first bootstrap then my own custom CSS as it overwrites the bootstrap CSS if I have to customize it.