部署到Azure后,ASP.Net MVC应用程序中丢失了自定义引导样式和字体 [英] Lost custom bootstrap styles and fonts in ASP.Net MVC application after deployment to Azure

查看:42
本文介绍了部署到Azure后,ASP.Net MVC应用程序中丢失了自定义引导样式和字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在bootstrap.css文件中添加了一些@ font-face声明,以及在部署到Azure App Service后我没有看到的一些颜色和格式修改。由于某种原因,它无法找到bootstrap.css我在想,不知道什么是
在Azure中运行与在本地工作的不同。这是声明。

I've added some @font-face declarations in my bootstrap.css file as well as some color and formatting modifications that I'm not seeing after deploying to an Azure App Service. For some reason it can't find the bootstrap.css I'm thinking, not sure what would be different running in Azure vs. locally where it's working. Here's the declaration.

@ font-face {

    font-family:" English Towne Medium;;
    src:url(" /fonts/Engtowne.eot?#iefix")格式("eot"), 

        url(" /fonts/Engtowne.woff")格式(" woff"), 

        url(" /fonts/Engtowne.ttf")格式(" truetype"), 

        url(" /fonts/Engtowne.svg#EnglishTowne-Medium")格式(" svg");

    font-weight:100;

    font-style:normal;

}

@font-face {
    font-family: "English Towne Medium";
    src: url("/fonts/Engtowne.eot?#iefix") format("eot"), 
        url("/fonts/Engtowne.woff") format("woff"), 
        url("/fonts/Engtowne.ttf") format("truetype"), 
        url("/fonts/Engtowne.svg#EnglishTowne-Medium") format("svg");
    font-weight: 100;
    font-style: normal;
}

所有字体文件已经部署,我尝试过使用带有"/ fonts"的src url paramaeter和"../字体"

All the font files have been deployed and I've tried using the src url paramaeter with "/fonts" and "../fonts"

这是BundlesConfig ..

Here's the BundlesConfig..

        //有关捆绑的详细信息,请访问https://go.microsoft.com/fwlink/?LinkId=301862

        public static void RegisterBundles(BundleCollection包)

        {

            bundles.Add(新ScriptBundle(QUOT;〜/束/的jquery"。),可以列举(

           &NBSP ;"〜/ Scripts / jquery- {version} .js"));
$


            bundles.Add(新ScriptBundle(QUOT;〜/捆绑/ jqueryval"。),可以列举(

           &NBSP ;"〜/ Scripts / jquery.validate *"));
$


            //使用Modernizr的开发版本进行开发和学习。然后,当你是
            //准备投入生产,使用https://modernizr.com上的构建工具仅选择您需要的测试。

            bundles.Add(新ScriptBundle(QUOT;〜/束/ Modernizr的"。),可以列举(

           &NBSP ;"〜/ Scripts / modernizr - *"));
$


            bundles.Add(新ScriptBundle(QUOT;〜/束/自举"。),可以列举(

           " ;〜/ Scripts / bootstrap.js"));
$


            bundles.Add(new StyleBundle("〜/ Content / css")。包括(

           " ;〜/ Content / bootstrap.css",&
           "〜/ Content / site.css" ));)
        }

        // For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

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

            // Use the development version of Modernizr to develop with and learn from. Then, when you're
            // ready for production, use the build tool at https://modernizr.com to pick only the tests you need.
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));

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

            bundles.Add(new StyleBundle("~/Content/css").Include(
                      "~/Content/bootstrap.css",
                      "~/Content/site.css"));
        }

任何想法..?

谢谢,

Dan

推荐答案

感谢您的提问!上述情况可能是由于捆绑框架在本地/调试模式下使用 bootstrap.css &n   bootstrap.min.css  当您部署
时。在确定要添加到捆绑包的文件时,框架使用一组约定,其中一个是使用文件的.min版本(如果存在),用于发布版本。

Thanks for the question! The above situation could be likely due to the bundling framework using bootstrap.css in local/debug mode and bootstrap.min.css when you deploy. The framework uses a set of conventions when determining which files to add to a bundle, one of which is to use the .min version of a file, if it exists, for release builds.

建议您可以尝试删除  bootstrap.min.css  并重新部署。这应该强制框架缩小并使用您修改的 bootstrap.css  文件
。同时清除浏览器缓存。

Suggestion for this could be you can try deleting bootstrap.min.css and re-deploying. This should force the framework to minify and use the bootstrap.css file that you modified. Also clear your browser cache.





这篇关于部署到Azure后,ASP.Net MVC应用程序中丢失了自定义引导样式和字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆