gpt4 book ai didi

c# - 捆绑和缩小返回 404

转载 作者:太空狗 更新时间:2023-10-29 21:04:57 25 4
gpt4 key购买 nike

  1. System.Web.Optimization已安装
  2. bundle 已经配置如下

    using System.Web.Optimization;
    public class BundleConfig
    {
    public static void RegisterBundles(BundleCollection bundles)
    {
    bundles.Add(new ScriptBundle("~/Content/themes/base/js").Include("~/Scripts/Site.js"));
    bundles.Add(new StyleBundle("~/Content/themes/base/css").Include("~/Content/Site.css"));

    }
    }
  3. 将此添加到 Layout.cshtml

    @System.Web.Optimization.Scripts.Render("~/Content/themes/base/js")
    @System.Web.Optimization.Styles.Render("~/Content/themes/base/css")

css 压缩成功但 js 文件返回 404 错误?

最佳答案

确保您的包 Content/themes/base/js 的虚拟路径与真实路径无关。出于这个原因,我们通常在虚拟路径中使用 ~/bundles

示例

public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/base/js").Include("~/Scripts/Site.js"));
bundles.Add(new StyleBundle("~/bundles/base/css").Include("~/Content/Site.css"));

}

关于c# - 捆绑和缩小返回 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18698001/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com