Bundling scripts are not getting rendered

前端 未结 4 1127
梦谈多话
梦谈多话 2020-12-04 02:08

I am having a problem with script bundling and minification with ASP .NET I have tried all popular solution found on internet but still having the same problem.

My <

相关标签:
4条回答
  • 2020-12-04 02:28

    Have you tried using non existing directory in Bundle's virtual path? Like

    ...new ScriptBundle("~/bundle/Scripts")...
    
    0 讨论(0)
  • 2020-12-04 02:33

    The bundle module logic that decides whether or not to handle a request, will not takeover requests to existing files or directories. So that's why your bundle requests don't work when they live at the same virtual path as an existing directory (or file).

    0 讨论(0)
  • 2020-12-04 02:35

    You can't give your bundle a name that is also the name of an existing directory. Rename the bundle or add a /js to make it work correctly:

    bundles.Add(new ScriptBundle("~/Scripts/js").IncludeDirectory("~/Scripts", "*.js").IncludeDirectory("~/Scripts/kendoui", "*.js"));
    

    and

    @Scripts.Render("~/Scripts/js")
    

    Any other name that doesn't exist would work as well, e.g.

     bundles.Add(new ScriptBundle("~/ScriptMonkey").IncludeDirectory("~/Scripts", "*.js").IncludeDirectory("~/Scripts/kendoui", "*.js"));
    

    ...assuming you don't have /ScriptMonkey directory.

    0 讨论(0)
  • 2020-12-04 02:35

    The accepted answer did not work for me. I use MVC 4.0 on Visual Studio 2010 SP1. I had a js file named "jquery-ui.min.js" file and was not getting loaded. My Bundle.config code was:

    bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(                        
                                "~/Scripts/jquery-ui.min.js"));
    

    I renamed the file to jquery-ui.js and updated my code as

    bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(                        
                            "~/Scripts/jquery-ui.js"));
    

    I got this information from here.

    0 讨论(0)
提交回复
热议问题