Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top