1

This is a new MVC5 project, created from the blank ASP.NET template.

Here's my bundle registration:

Imports System.Web.Optimization

Public Class BundleConfig
  Public Shared Sub RegisterBundles(Bundles As BundleCollection)
    Bundles.Add(New StyleBundle("~/styles/main").Include("~/Styles/Layout.css"))
  End Sub
End Class

...here's the relevant section of my view:

@Code
  Me.Layout = Nothing
End Code

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>

  @Styles.Render("~/styles/main")
</head>

... and here's the HTML output:

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>

  <link href="/styles/main" rel="stylesheet"/>
</head>

Note that the link's href should instead be:

  <link href="/Styles/Layout.css" rel="stylesheet"/>

All of this of course results in a 404 error.

Things I've tried:

  1. Followed the general guidance from the official documentation
  2. Added a CssRewriteUrlTransform object, as indicated here
  3. Both enabled and disabled Optimization, as indicated here
  4. Updated the WebGrease package to the latest version
  5. Checked Web.config for an umbracoReservedPaths key, as indicated here (none exists)
  6. Added Bundles.IgnoreList.Clear() as indicated here

This exact construct is working correctly in another project, so obviously something's different. But I'm unable to spot it.

How can I get this bundle to render properly?

InteXX
  • 6,135
  • 6
  • 43
  • 80
  • You called it `"~/styles/main"` so that is what it is – Mark Schultheiss Jul 13 '21 at 21:08
  • `~/styles/main` is the key (note the tilde, which isn't rendered in the incorrect link). The renderer is supposed to return `/Styles/Layout.css` for that key. This same construct also works correctly in another project. – InteXX Jul 14 '21 at 23:16

0 Answers0