In my MVC4 project I bundle two css file. When browse render this file then I got two exception.
Uncaught SyntaxError: Unexpected token .
Uncaught SyntaxError: Unexpected token {
I wrote this code for bundling my CSS files.
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new StyleBundle("~/Content/css")
.Include("~/Content/css3.css","~/Content/styles.css"));
}
I call this in my _Layout.chshtml page.
<head>
@Scripts.Render("~/Content/css")
</head>
and get that exception.
But if I call those CSS files this way then every thing works fine.
<head>
<link href="~/Content/css3.css" rel="stylesheet" />
<link href="~/Content/styles.css" rel="stylesheet" />
</head>
Here is a screen shoot of my Error.
It's because it's rendering a <script>
tag. It should be @Styles.Render
instead of @Scripts.Render
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With