I met an issue, strange in my point of view.
I installed bootstrap via nuget package console.
After that, in BundleConfig.cs
file, I added two items to bundles
list:
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( "~/Scripts/bootstrap.min.js")); bundles.Add(new StyleBundle("~/Content/bootstrap").Include( "~/Content/bootstrap.min.css", "~/Content/bootstrap-theme.min.css"));
Of course, these files exist locally.
The _Layout.cshtml
file contains
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width" /> <title>@ViewBag.Title</title> @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/modernizr") @Styles.Render("~/Content/bootstrap") </head> <body> @RenderBody() @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/bootstrap") @RenderSection("scripts", required: false) </body> </html>
But when I see a view (for example login page), I see that bundle doesn't append bootstrap part.
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width" /> <title>Login</title> <link href="/Content/Site.css" rel="stylesheet"/> <script src="/Scripts/modernizr-2.6.2.js"></script> <!-- I expect bootstrap here but it is not displayed --> </head> <body> ... <script src="/Scripts/jquery-1.9.1.js"></script> <!-- I expect bootstrap here but it is not displayed --> </body> </html>
Go to the References folder right click on the folder >Find>Manage NuGet Packages>Click on the option. Install bootstrap package. Bootstrap is installed automatically and css files are saved in content folder and js files are saved in script folder.
Bundling is a new feature in ASP.NET 4.5 that makes it easy to combine or bundle multiple files into a single file. You can create CSS, JavaScript and other bundles. Fewer files means fewer HTTP requests and that can improve first page load performance.
To install the Bootstrap Snippet Pack, from Visual Studio, go to Tools, then Extensions and Updates > Online > Search Bootstrap Snippet Pack. Once Installed, from Visual Studio editor, hit CTL+K, CTL+X to bring in the snippet tool. Then select Bootstrap and the component needed.
To improve the performance of the application, ASP.NET MVC provides inbuilt feature to bundle multiple files into a single, file which in turn improves the page load performance because of fewer HTTP requests.
When using Bundle, do not append the .min
bundles.Add(new StyleBundle("~/Content/bootstrap").Include( "~/Content/bootstrap.css", "~/Content/bootstrap-theme.css"));
Based on the debug setting, (mostly web.config)
debug="true"
- the non minified version will be used. debug="false"
- *.min.css
will be searched, and if not found, the current will be minifiedweb.config setting:
<system.web> <compilation debug="true"...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With