Style bundler rendering link incorrectly

114 Views Asked by At

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?

0

There are 0 best solutions below