mehrdad
mehrdad

Reputation: 114

Mvc razor bundles

I created a layout in ASP.NET MVC, and I used a script bundle for loading jQuery library, but jQuery is not loaded.

My layout looks like this:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
</head>
<body>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

and my bundle file is

  bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

Please help me !

Upvotes: 0

Views: 1930

Answers (1)

Kartikeya Khosla
Kartikeya Khosla

Reputation: 18873

Your code in question is correct i.e you are including bundles correctly,there may be problem in your bundleconfig file or you are not including bundles correctly in view.

Use @section scripts{ } in .cshtml Views as shown :-

 @section scripts{
   <script type="text/javascript">
    $(document).ready(function () {

     });
   </script>
 }

Upvotes: 4

Related Questions