0

I recently upgraded a MVC 3 project to MVC 4.

In the app there are 3 areas. The areas use the same scripts as elsewhere.

Before the upgrade views in areas just used scripts from the Main Scripts folder ( /Scripts) but now I get a 404 (Not Found) because its looking here - /AREANAME/Scripts/jquery-1.10.1.min.js

Obviously I dont want to duplicate the scripts folder to all the areas folders so my question is how do I make the areas use the scripts in the main folder?

I reference the scripts like this in layout page

Toby Holland
  • 1,029
  • 2
  • 14
  • 29

2 Answers2

3

Don't use relative addressing. Instead, use the MVC supplied tools for this:

<script src="@Url.Content("~/Scripts/jquery-1.10.1.min.js")"></script>

Even better, use the bundling and minification supplied tools in MVC4.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
0

Thanks Mystere Man for the answer. For .aspx views it is like this

<script type="text/javascript" src="<%=Url.Content("~/Scripts/jquery-1.10.1.min.js")%>"></script>
Toby Holland
  • 1,029
  • 2
  • 14
  • 29