Reputation: 19933
I'd like in an .cshtml
page, insert an .js
page.
I tried this :
<script src="@Url.Content("~/Scripts/MyFile.js")" type="text/javascript"></script>
No problem with the same code in the shared/_layout.cshtml
(in the header section)
When I execute the application, this file is not present in the source code (not include).
Any idea ?
Thanks,
Upvotes: 0
Views: 13724
Reputation: 14944
try:
<script src="@Url.Content("../../Scripts/MyFile.js")" type="text/javascript"></script>
Upvotes: 1
Reputation: 337733
Your code is correct (assuming you are using Razor templating in MVC3). The only way this would not work is if the path to your script is wrong.
Upvotes: 0