Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught SyntaxError: Unexpected token exception after bundle two CSS file in MVC4

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.

enter image description here

like image 248
Hasanuzzaman Avatar asked Apr 21 '13 19:04

Hasanuzzaman


1 Answers

It's because it's rendering a <script> tag. It should be @Styles.Render instead of @Scripts.Render.

like image 175
greg84 Avatar answered Nov 14 '22 21:11

greg84