1

I'm working on an ASP.Net Core 1.0 site project I inherited from when it was RC1... We've moved it to .NETCoreApp ver 1.0 now via started a new project with the latest template and migrated the code over. 95% works now except signalR (of course) and some UI particulars... (This whole new way of 'gulp' and 'sass' and all gets confusing.)

So, my site is working, but when I click what should open a modal, it disappears almost instantly. From what I read (and have done before in MVC 5) is that I must have included the bootstrap bundle twice or referenced it twice in some fashion.

Previously, in MVC 5, the _Layout would have something like:

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

and then in App_Start/BunfleConfig.cs would be:

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

and the various css as well in this fashion...

in the 'new', I am having trouble understanding the whole gulp

-to-wwwroot process and the project.json controlling what gets included/excluded in publishOptions... I don't know if I am coming or going...

Basically, my modals are opening and closing instantly... bootstrap included twice?.. how to investigate?

And where to include bootstrap/jquery? under Bower or NPM?

I run the gulpfile method to minify and move the js/css/sass into the wwwroot area:

Here is where I have them now.

1
  • 1
    if bootstrap was loaded twice you would see it in your browser's webinspector.. Is it?
    – Mike_G
    Sep 16, 2016 at 13:28

1 Answer 1

0

I am having trouble understanding the whole gulp-to-wwwroot process and the project.json controlling what gets included/excluded in publishOptions... I don't know if I am coming or going...

Could you post your gulpfile? Also, here's a reference for project.json: https://learn.microsoft.com/en-us/dotnet/articles/core/tools/project-json#publishoptions

If you think bootstrap is being included twice, there are a lot of things that could be causing it. I'll list a few of them.

  • You could be combining all of your sources into one file and also including it separately. Check your _Layout.cshtml for .js and .css references. For example, gulp may be combining bootstrap and all of your other libs into something like site.js. If you include site.js and it already includes bootstrap, make sure you're not including bootstrap.js again.

  • You might have bootstrap.js in your _Layout.cshtml file, and again in the view page (Index.cshtml, etc).

Another thing I would try is when you're browsing the page that is experiencing the problem, view the source for the page and see if you notice bootstrap being included in there twice. If it's only in there once, try removing it and see if that fixes the problem - that may be a hint that it's getting included in the gulp task.

And where to include bootstrap/jquery? under Bower or NPM?

A lot of people I have spoken to are starting to abandon Bower and solely use NPM. They both still work, and I believe the default templates still include it in Bower. However, I just recently moved all of mine over to NPM in one of my projects. Doing so does add some complexity though as you have to tweak the gulpfile even more to move everything to the right place. I found using Bower easier for things like Bootstrap, jQuery, etc..., but that's me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.