【问题标题】:Fonts are not rendered correctly in Release Mode, but is working on Debug Mode in ASP NET Webforms字体在发布模式下未正确呈现,但在 ASP NET Webforms 中的调试模式下工作
【发布时间】:2015-12-17 23:19:38
【问题描述】:

我们能够在 VS2013 发布期间解决有关字体渲染的问题。

app.css”和“style.css”字体中的字体网址指向一个位置,例如“fonts/icomoon” .eot”,从技术上讲,它无法根据 IIS 的目录浏览找到具体路径。

我们通过将“/Content/stylesheets/”添加到所有当前看起来像“/Content/”的字体网址来更改它stylesheets/fonts/icomoon.eot" 它工作了

但是我们仍然不明白为什么调试模式可以正常使用我们的 css 文件和字体的以前的 url。

您能提出任何解决办法吗?还是我们的这个修复可以(手动编辑 css 文件中的 font-urls)?

【问题讨论】:

    标签: css asp.net fonts webforms webfonts


    【解决方案1】:

    我们为字体问题找到了更好的解决方案。

    asp.net 捆绑是导致它们在 debugrelease 模式之间产生不同结果的原因。

    默认情况下,如果编译处于调试模式,则关闭捆绑,如果处于发布模式,则打开。

    为了解决这个问题,我们在发布模式下关闭了 asp.net 捆绑,方法是将此行添加到 BundleConfig.Cs

    BundleTable.EnableOptimizations = false;

    asp.net 捆绑的作用是为所有 css 和 js 文件创建一个虚拟目录。问题是它在 css 文件中找不到 URL(特别是字体)的路径。

    但我们尝试过的另一个解决方案是:

    bundles.Add(new StyleBundle("~/bundles/LayoutCss").Include(
                "~/Content/stylesheets/style.css", new CssRewriteUrlTransform() )
                .Include("~/Content/stylesheets/app.css", new CssRewriteUrlTransform() )
                .Include("~/Content/bower_components/slick/dist/slick.css"));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多