1

I'm trying to minify some files with BundleConfig, everything looks to be ok, the problem is when I try to use @Styles.Render and @Scripts.Render, when I use those renders on the HTML I get a loop of errors and of course the page doesn't load, I think the render can't find the virtual path.

So my question is, what else should I do or what I'm missing on my setup for the HTML to recognize virtual bundle files?


Here is the error message trace on the loop, this loops indefinitely:

Exception thrown: 'System.ArgumentException' in mscorlib.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
The thread 0x3ee8 has exited with code 0 (0x0).

This is my setup at the moment:

BundleConfig

    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/js").Include(
                    "~/Assets/dist/js/app.js",
                    "~/Assets/dist/js/main.js"));

        bundles.Add(new StyleBundle("~/Style/css").Include(
                  "~/Assets/dist/css/app.css",
                  "~/Assets/dist/css/main.css"));

        // This is a test, I read that Bundle can be use instead of ScriptBundle/StyleBundle
        // Didn't work
        bundles.Add(new Bundle("~/Content/css").Include(
                  "~/Assets/dist/css/app.css",
                  "~/Assets/dist/css/main.css"));


        // This is because I'm in DEBUG mode 
        BundleTable.EnableOptimizations = true;
    }

Global.asax.cs

    protected void Application_Start(object sender, EventArgs e)
    {
        . . .
        BundleConfig.RegisterBundles(BundleTable.Bundles);
    }

base.cshtml

@using System.Web.Optimization;

. . .

@Styles.Render("~/Content/css")

. . .

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

I also had try this in my web.config, but I removed it since is a redundant reference:

<add namespace="System.Web.Optimization"/>
davidrl1000
  • 311
  • 1
  • 4
  • 16
  • Found nothing wrong in your provided code with naked eye. – TanvirArjel Jan 30 '19 at 16:14
  • If you can log the exception with stack trace, it will show where the exception thrown. The bundling code itself seem look fine but there's something went wrong inside the worker process. – Tetsuya Yamamoto Jan 31 '19 at 03:45
  • @TetsuyaYamamoto yeah the exception is thrown on the Styles.Render/Script.Render lines, the exception says that the virtualpath doesn't exist. – davidrl1000 Jan 31 '19 at 15:38

0 Answers0