Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gianni Declercq 8 posts 80 karma points
    Mar 26, 2020 @ 10:04
    Gianni Declercq
    0

    MVC Bundles not working Umbraco 8

    I'm trying to use an MVC BundleConfig for my CSS and Scripts. But in release mode I always get a 404 not found when loading these assets.

    My bundleconfig:

    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));
    
        bundles.Add(new ScriptBundle("~/bundles/js/iziModal.min.js", 
            "https://cdnjs.cloudflare.com/ajax/libs/izimodal/1.5.1/js/iziModal.min.js").Include(
            "~/assets/js/iziModal.min.js"));
    
        bundles.Add(new ScriptBundle("~/bundles/js").Include(
              "~/assets/js/main.js", "~/assets/js/vendor.js"));
    
        bundles.Add(new StyleBundle("~/bundles/css").Include(
                    "~/assets/css/main.css"));
    
        #if DEBUG
                BundleTable.EnableOptimizations = false;
        #else
                BundleTable.EnableOptimizations = true;
        #endif
    }
    

    I also registered the config at startup

    BundleConfig.RegisterBundles(BundleTable.Bundles);
    

    And..

    <add key="Umbraco.Core.ReservedPaths" value="~/.well-known/,~/bundles/" />
    

    What am I doing wrong here?

  • Yakov Lebski 554 posts 2118 karma points
    Mar 27, 2020 @ 18:08
    Yakov Lebski
    0

    How you call RegisterBundles ?

  • Anna 16 posts 110 karma points
    Oct 01, 2020 @ 10:05
    Anna
    1

    Gianni, did you find out what was wrong? I have the same problem.

    I call my registerbundles like this:

    public class ApplicationComponent : IComponent
        {
            public void Initialize()
            {
                BundleConfig.RegisterBundles(BundleTable.Bundles);
            }
    
            public void Terminate()
            { }
        }
    

    The tags with urls get generated, but I get "Not Found".

    If I copy the generated path to a style sheet and paste it into the browser, it does open the file. So it is there but not found...

    Any help would be appreciated.

  • Anna 16 posts 110 karma points
    Oct 01, 2020 @ 10:31
    Anna
    101

    Found the solution in case somebody is having the same problem.

    You also need to add these values to Web.Config

    <add key="Umbraco.Core.ReservedUrls" value="~/bundles/, ~/css/" />
    

    Note, this is ReservedUrls. I only had them in ReservedPaths.

Please Sign in or register to post replies

Write your reply to:

Draft