Just stumbled upon this question and would like to add a comment, which can be done in a more elegant way in Visual Studio 2013.
On the main page, simply enter the following code at the bottom of the page (on the main page created by default, this code already exists):
<body> ... @RenderSection("scripts", required: false) </body> </html>
Then, in your opinion, the following code is at the bottom below:
@section scripts { <script src="...script url..."></script> }
or if you use packages
@section scripts { @Scripts.Render("~/bundles/<script id>") }
or you can put a <script> ... </script> section with your Javascript code in the @section script block in the view.
source share