【问题标题】:Sitecore 8, .NET 4.6, Bundles Returning 404Sitecore 8、.NET 4.6、返回 404 的捆绑包
【发布时间】:2015-11-22 09:33:38
【问题描述】:

我在 .NET 4.6 上运行 Sitecore 8(更新 5)并且遇到了 Bundles 返回 404 错误的问题。

我的布局视图:

@using Sitecore.Mvc.Presentation
@using Sitecore.Mvc

@model RenderingModel

    <!DOCTYPE html>
    <html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>@Model.Item.Fields["Title"]</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
    </head>
    <body>
        <h1>@Html.Sitecore().Field("Title")</h1>
        @Html.Sitecore().Placeholder("content")

        <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>
        <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js" type="text/javascript" defer="defer"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
        @Scripts.RenderFormat("<script type=\"text/javascript\" src=\"{0}\" defer=\"defer\"></script>", "~/bundles/scripts/footer")
    </body>
    </html>

我的 /Global.asax.cs 文件:

using System.Web.Mvc;
using System.Web.Optimization;
using Glass.Mapper.Sc;

namespace Sitecore.Web
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }

        protected void Application_BeginRequest()
        {
            Sitecore.Context.Items["Disable"] = new VersionCountDisabler();
        }
    }
}

我的 /App_Start/BundleConfig.cs 文件:

using System.Web.Optimization;

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/scripts/footer").Include(
            "~/Assets/js/jquery.validate.js",
            "~/Assets/js/additional-methods.js",
            "~/Assets/js/form.js",
            "~/Assets/js/marketo.js"
        ));


        #if DEBUG
            BundleTable.EnableOptimizations = false;
        #else
            BundleTable.EnableOptimizations = true;
        #endif
    }
}

我的 /Web.config&lt;system.webServer&gt;/modules 部分:

<modules runAllManagedModulesForAllRequests="true">
  <remove name="WebDAVModule" />
  <add type="Sitecore.Web.RewriteModule, Sitecore.Kernel" name="SitecoreRewriteModule" />
  <add type="Sitecore.Nexus.Web.HttpModule,Sitecore.Nexus" name="SitecoreHttpModule" />
  <add type="Sitecore.Resources.Media.UploadWatcher, Sitecore.Kernel" name="SitecoreUploadWatcher" />
  <add type="Sitecore.IO.XslWatcher, Sitecore.Kernel" name="SitecoreXslWatcher" />
  <add type="Sitecore.IO.LayoutWatcher, Sitecore.Kernel" name="SitecoreLayoutWatcher" />
  <add type="Sitecore.Configuration.ConfigWatcher, Sitecore.Kernel" name="SitecoreConfigWatcher" />
  <remove name="Session" />
  <add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition="" />
  <add type="Sitecore.Analytics.RobotDetection.Media.MediaRequestSessionModule, Sitecore.Analytics.RobotDetection" name="MediaRequestSessionModule" />
  <add type="Sitecore.Web.HttpModule,Sitecore.Kernel" name="SitecoreHttpModuleExtensions" />
  <add name="SitecoreAntiCSRF" type="Sitecore.Security.AntiCsrf.SitecoreAntiCsrfModule, Sitecore.Security.AntiCsrf" />
  <remove name="BundleModule"/>
  <add type="System.Web.Optimization.BundleModule" name="BundleModule"/>
</modules>

最后,由 /sitecore/admin/showconfig.aspx 显示的显示 /bundles 的 IgnoreUrlPrefixes 设置包含在列表中:

<!--
  IGNORE URLS
            Set IgnoreUrlPrefixes to a '|' separated list of url prefixes that should not be
            regarded and processed as friendly urls (ie. forms etc.)

-->
<setting name="IgnoreUrlPrefixes" value="/sitecore/default.aspx|/trace.axd|/webresource.axd|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.DialogHandler.aspx|/sitecore/shell/applications/content manager/telerik.web.ui.dialoghandler.aspx|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.SpellCheckHandler.axd|/Telerik.Web.UI.WebResource.axd|/sitecore/admin/upgrade/|/layouts/testing|/bundles|/Assets"/>

更新:请参阅下面接受的答案。

【问题讨论】:

  • 不要认为 sitecore 已经为 4.6 做好了准备。还没有做回归测试。 8.0 刚刚与 4.5 和 mvc 5.2 一起发布。可能会在 4.6 被推送之前(或至少在它被支持之前)。
  • 我将构建目标更改为 4.5 并且发生了相同的行为。 404错误页面表明Handler是StaticFile,对我来说是不正确的。

标签: sitecore asp.net-optimization sitecore-mvc sitecore8


【解决方案1】:

我发现了问题所在。我的 Global.asax 标记的“继承”属性与 Global.asax.cs 中的类名不匹配。

【讨论】:

【解决方案2】:

实验时间:

  1. 删除您的编译器指令。 &lt;compilation debug="true|false"&gt; 应该在运行时控制它。
  2. 删除您的 web.config &lt;module&gt; 条目。我发现即使是 Sitecore 7.2 项目也不需要这样做。

【讨论】:

  • 试过这些。行为没有变化。
  • 磁盘上没有名为 /bundles 的物理文件夹?
  • 磁盘上没有名为 /bundles 的物理文件夹。
  • 使用 /bundles 以外的虚拟路径?
猜你喜欢
  • 1970-01-01
  • 2013-09-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-01
  • 1970-01-01
  • 2015-09-09
  • 2017-08-12
相关资源
最近更新 更多