Sitecore 8, .NET 4.6, Bundles Returning 404
Asked Answered
P

2

7

I am running Sitecore 8 (Update 5) on .NET 4.6 and am running into an issue with Bundles returning a 404 error.

My layout view:

@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>

My /Global.asax.cs file:

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();
        }
    }
}

My /App_Start/BundleConfig.cs file:

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
    }
}

The <system.webServer>/modules section of my /Web.config:

<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>

And lastly, the IgnoreUrlPrefixes setting as displayed by /sitecore/admin/showconfig.aspx that shows /bundles is included in the list:

<!--
  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"/>

UPDATE: See accepted answer below.

Proceed answered 27/8, 2015 at 20:32 Comment(2)
Don't think sitecore is ready for 4.6 yet. Still haven't done regression tests. 8.0 just released with 4.5 and mvc 5.2. Probably going to be a bit before 4.6 gets pushed (or at least until it's supported).Retrogress
I changed the build target to 4.5 and the same behavior occurs. The 404 error page indicates that the Handler is StaticFile, which to me would be incorrect.Proceed
P
2

I discovered what the issue was. The "inherits" attribute of the markup of my Global.asax did not match the class name in the Global.asax.cs.

Proceed answered 31/8, 2015 at 16:20 Comment(2)
Tricky. I like to use WebActivatorEx as an alternative to modifying the Global.asax.Bramble
@Proceed Maybe you can help me. Look at this : #57904986Elianaelianora
B
0

Time to experiment:

  1. Remove your compiler directives. <compilation debug="true|false"> should control that at runtime.
  2. Remove your web.config <module> entries. I've found this hasn't been necessary for even Sitecore 7.2 projects.
Bramble answered 28/8, 2015 at 1:56 Comment(4)
Tried these. No change in behavior.Proceed
No physical folder named /bundles on disk?Bramble
No physical folder named /bundles on disk.Proceed
Use a virtual path other than /bundles?Bramble

© 2022 - 2024 — McMap. All rights reserved.