Difference Between Script Rendering Code in Razor

asp.net-mvc, razor

Solution

The first one renders out a bundle, which is a group of related Javascript files. For instance, you might want to bundle jQuery and jQuery UI together. Bundles also get the benefit of bundling and minification when a solution is compiled in release mode. ref: http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification

`@RenderSection` indicates that a page that uses the layout in question can inject markup in a particular spot in the layout. Sections are in effect a placeholder (and work much like the `ContentPlaceHolder` server control from web forms if you are familiar with that). That reference is probably right before the closing body tag, where it is believed by some to be the best spot to put scripts. You could have a section called `scripts`, or `head`, or `footer`, it is completely arbitrary and sections don't necessarily have anything to do with scripts at all. ref: http://weblogs.asp.net/scottgu/asp-net-mvc-3-layouts-and-sections-with-razor

Problem

When I create an MVC project that uses Razor, the following lines are generated: ``` @Scripts.Render("~/bundles/jquery") @RenderSection("scripts", false) ``` What is the difference between these lines ? Is it the case that `@Scripts.Render` generates a `<scripts>` section and then `@RenderSection("scripts", false)` renders it ?

Original source