资源被解释为样式表,捆绑无效

时间:2019-03-19 09:45:55

标签: c# asp.net bundling-and-minification

我看过类似的问题,其中大多数是人们在JS文件上使用了Style.Render,反之亦然。

问题是,我找不到差异,要么就是盲目。有趣的事实是,我的母版页上的脚本可以正常工作,除了缺少字体的字体外,没有显示任何错误。这仅在登录页面上发生。在控制台上只需说

  

解释为MIME文本的资源

并抛出错误:

  

意外令牌<< / p>

捆绑销售

这是我的登录页面标题

<head runat="server">
<title></title>

<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport" />


    <%: Styles.Render("~/Content/adminlte") %>
    <%: Styles.Render("~/Content/login-form") %>
    <%: Styles.Render("~/Content/fontawesome") %>
    <%: Styles.Render("~/Content/iziToast") %>
    <%: Styles.Render("~/Content/css") %>

    <%: Scripts.Render("~/Bundles/jquery") %>
    <%: Scripts.Render("~/Bundles/adminlte") %>
    <%: Scripts.Render("~/Bundles/jqueryval") %>
    <%: Scripts.Render("~/Bundles/fontawesome") %>
    <%: Scripts.Render("~/Bundles/iziToast") %>
    <%: Scripts.Render("~/Bundles/js") %>
</head>

这是母版页眉

<head runat="server">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />


<title></title>

<%: Styles.Render("~/Content/adminlte") %>
<%: Styles.Render("~/Content/fontawesome") %>
<%: Styles.Render("~/Content/iziToast") %>
<%: Styles.Render("~/Content/css") %>

<%: Scripts.Render("~/Bundles/jquery") %>    
<%: Scripts.Render("~/Bundles/adminlte") %>
<%: Scripts.Render("~/Bundles/jqueryval") %>
<%: Scripts.Render("~/Bundles/fontawesome") %>
<%: Scripts.Render("~/Bundles/iziToast") %>
<%: Scripts.Render("~/Bundles/js") %>


<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>

</head>

BundleConfig中的App_Start

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {      
        bundles.Add(new ScriptBundle("~/Bundles/jquery").Include(
           "~/Scripts/jquery-{version}.js"));

        //bundles.Add(new ScriptBundle("~/Bundles/angular").Include(
        //    "~/Scripts/angular.js"));

        bundles.Add(new ScriptBundle("~/Bundles/adminlte").Include( 
          "~/AdminLTE/dist/js/adminlte.js",                         
          "~/AdminLTE/plugins/bootstrap/js/bootstrap.bundle.js",
          "~/AdminLTE/plugins/datatables/jquery.dataTables.js",
          "~/AdminLTE/plugins/datatables/dataTables.bootstrap4.js"));

        bundles.Add(new ScriptBundle("~/Bundles/jqueryui").Include(
      "~/Scripts/jquery-ui-{version}.js"));

        bundles.Add(new ScriptBundle("~/Bundles/jqueryval").Include(
            "~/Scripts/jquery.unobtrusive*",
            "~/Scripts/jquery.validate*"));

        bundles.Add(new ScriptBundle("~/Bundles/js").Include(
        "~/Scripts/masterpages/menu-selection.js",
        "~/Scripts/masterpages/notification.js",
        "~/Scripts/masterpages/main.js",
        "~/Scripts/masterpages/datatables.js",
        "~/Scripts/pages/validation.js"));

        bundles.Add(new ScriptBundle("~/Bundles/fontawesome").Include(
            "~/Scripts/fontawesome/all.js"));

        bundles.Add(new ScriptBundle("~/Bundles/iziToast").Include(
            "~/Scripts/iziToast/iziToast*"));

        bundles.Add(new ScriptBundle("~/Bundles/modernizr").Include(
           "~/Scripts/modernizr-*"));


        bundles.Add(new StyleBundle("~/Content/login-form").Include(
               "~/Content/Login/login-inventario.css"));

        bundles.Add(new StyleBundle("~/Content/fontawesome").Include(
            "~/Content/fontawesome-all*"));

        bundles.Add(new StyleBundle("~/Content/adminlte").Include(
         "~/AdminLTE/dist/css/adminlte*",
         "~/AdminLTE/plugins/datatables/dataTables.bootstrap4.css",
         "~/AdminLTE/plugins/datepicker/datepicker3.css"));

        bundles.Add(new StyleBundle("~/Content/iziToast").Include(
            "~/Content/iziToast*"));

        bundles.Add(new StyleBundle("~/Content/css").Include(
           "~/Content/masterpages/sidebar.css",
           "~/Content/masterpages/custom.css",
             "~/Content/masterpages/layout.css",
             "~/Content/masterpages/fieldset.css",
           "~/Content/masterpagess/validation.css"));
    }
}

我一遍又一遍地检查了文件,我确定js和css文件在正确的位置。

编辑

仅当我在Web配置中将debug设置为false时,才会发生这种情况。但是当我将其发布到IIS时,它将再次出现此问题

0 个答案:

没有答案