0

When I publish my core3.1 website to Azure the path to the css files returns a 404 www.mysite.com/css/StyleBundle.css

Here is my config.

app.UseWebOptimizer();
app.UseStaticFiles();

var cssSettings = new CssSettings();
var jsSettings = new CodeSettings();

if (_Environment.IsDevelopment())
{
    cssSettings = CssSettings.Pretty();
    jsSettings = CodeSettings.Pretty();
}

services.AddWebOptimizer(options =>
{
    //css/Less bundles
    options.AddLessBundle("/css/BootstrapBundle.css",
        "Styles/bootstrapmac.less")
        .MinifyCss(cssSettings)
        .UseContentRoot();
});

But when I add this AddCssBundle code, it does work in Azure.

       options.AddCssBundle("/css/ab.css",
            "Styles/a.css",
            "Styles/b.css")
        .UseContentRoot();
Terrence
  • 2,732
  • 2
  • 18
  • 12
  • 1
    It turns out that UseContentRoot() does not work in Azure. When I moved my Styles and Scripts folder from the root of my web project into the wwwroot folder and removed UseContentRoot() everything started to work. – Terrence Apr 28 '22 at 20:05

1 Answers1

0

"www.mysite.com/**css/StyleBundle.css" does not match your bundle name in:

options.AddLessBundle(**"/css/BootstrapBundle.css"**,
        "Styles/bootstrapmac.less")
        .MinifyCss(cssSettings)
        .UseContentRoot();

Change to: "www.mysite.com/**css/StyleBundle.css"

options.AddLessBundle(**"/css/StyleBundle.css"**,
        "Styles/bootstrapmac.less")
        .MinifyCss(cssSettings)
        .UseContentRoot();
Vega
  • 27,856
  • 27
  • 95
  • 103
  • Tim, I posted a bad example. I have about 5 bundles, I just pared it down to one for the example and didn't match the 404 error bundle with my config. The issues was the files were not in the Scripts folder of the "wwwroot" folder. – Terrence Jun 10 '22 at 01:48