在bundleconfig添加自举不asp.net mvc的工作

编程入门 行业动态 更新时间:2024-10-23 21:39:40
本文介绍了在bundleconfig添加自举不asp mvc的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在的观点遇到了一个问题,怪怪的。

我通过的NuGet包控制台安装引导。

之后,在 BundleConfig.cs 文件,我添加了两个项目包清单:

bundles.Add(新ScriptBundle(〜/包/引导)。包括(                    〜/脚本/ bootstrap.min.js));bundles.Add(新StyleBundle(〜/内容/引导)。包括(                     〜/内容/ bootstrap.min.css                     〜/内容/引导-theme.min.css));

当然,这些文件在本地存在。

的 _Layout.cshtml 文件包含

<!DOCTYPE HTML>< HTML和GT;< HEAD>    <间的charset =UTF-8/>    < META NAME =视口CONTENT =WIDTH =设备宽度/>    <标题> @ ViewBag.Title< /标题>    @ Styles.Render(〜/内容/ CSS)    @ Scripts.Render(〜/包/ Modernizr的)    @ Styles.Render(〜/内容/引导)< /头><身体GT;    @RenderBody()    @ Scripts.Render(〜/包/ jQuery的)    @ Scripts.Render(〜/包/引导)    @RenderSection(脚本,必需:false)< /身体GT;< / HTML>

但是,当我看到一个视图(例如登录页面),我看到包不追加引导一部分。

<!DOCTYPE HTML>< HTML和GT;< HEAD>    <间的charset =UTF-8/>    < META NAME =视口CONTENT =WIDTH =设备宽度/>    <标题>登录和LT; /标题>    <链接HREF =/内容/的site.css的rel =stylesheet属性/>    <脚本的src =/脚本/ Modernizr的-2.6.2.js>< / SCRIPT>    <! - 我希望在这里引导但不显示 - >< /头><身体GT;...<脚本的src =/脚本/ jQuery的-1.9.1.js>< / SCRIPT><! - 我希望在这里引导但不显示 - >< /身体GT;< / HTML>

解决方案

在使用捆绑,没有附加 .min

bundles.Add(新StyleBundle(〜/内容/引导)。包括(    〜/内容/ bootstrap.css    〜/内容/引导-theme.css));

根据调试设置(主要的web.config)

  • 调试=真正的 - 非缩小的版本将被使用。
  • 调试=false的 - * min.css 将被搜索,如果没有找到,。电流将精缩

web.config中设置:

<&的System.Web GT;  <编译调试=真?

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>

解决方案

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 minified

web.config setting:

<system.web> <compilation debug="true"...

更多推荐

在bundleconfig添加自举不asp.net mvc的工作

本文发布于:2023-11-15 16:59:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1596300.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工作   asp   bundleconfig   mvc   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!