Can't access the scripts which are placed within Areas. ASP MVC 3

364 views Asked by At

enter image description hereI am trying to access the scripts which are placed within the folder scripts created within Areas. But whenever i am trying to run the View, i am getting an error 404 saying the file was not found.

  <script src="/Areas/TestAreas/Scripts/AutoPostBack.js" type="text/javascript"></script>
1

There are 1 answers

8
Shyju On

You should include a ~ prefix when building the url to your file.

When razor sees ~/ It knows it has to get the file from the app root, So it will look for the remaining part(Areas/TestAreas/Scripts/AutoPostBack.js) from the app root .

This should work

<script src="~/Areas/TestAreas/Scripts/AutoPostBack.js" type="text/javascript"></script>