Twitter bootstrap glyphicons do not appear in release mode 404

前端 未结 7 1971
慢半拍i
慢半拍i 2020-12-24 11:55

I`m working on a project in ASP.NET MVC 4 and I did following steps:

  1. Downloaded twitter bootstrap from http://blog.getbootstrap.com/2013/12/05/bootstrap-3-

相关标签:
7条回答
  • 2020-12-24 12:36

    I had this problem and I found it was happening due to the minification when building in release mode.

    Rather than downloading the files manually from the bootstrap site and configuring bundling I use the nuget package which does it for me.

    If you would like to do that take the following steps.

    Run the following command to install Bootstrap:

    Install-Package Twitter.Bootstrap.MVC
    

    This downloads all the bootrap files and includes the below pre-defined Bootstrap bundle config:

    public class BootstrapBundleConfig
    {
        public static void RegisterBundles()
        {
            // Add @Styles.Render("~/Content/bootstrap") in the <head/> of your _Layout.cshtml view
            // For Bootstrap theme add @Styles.Render("~/Content/bootstrap-theme") in the <head/> of your _Layout.cshtml view
            // Add @Scripts.Render("~/bundles/bootstrap") after jQuery in your _Layout.cshtml view
            // When <compilation debug="true" />, MVC4 will render the full readable version. When set to <compilation debug="false" />, the minified version will be rendered automatically
            BundleTable.Bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include("~/Scripts/bootstrap.js"));
            BundleTable.Bundles.Add(new StyleBundle("~/Content/bootstrap").Include("~/Content/bootstrap.css"));
            BundleTable.Bundles.Add(new StyleBundle("~/Content/bootstrap-theme").Include("~/Content/bootstrap-theme.css"));
        }
    }
    

    The above also includes comments describing how to render out the bundles.

    I think the original 404 font error was due the fonts folder being at a different level to what is specified in the minified css.

    If you prefer to keep your current solution the only way I could fix the 404 was to copy the font folder to the root of the web application.

    To test it locally simply remove debug="true" from your web config to save deploying to AppHarbor.

    0 讨论(0)
提交回复
热议问题