I have my js files inside areas and I cannot access them. When I move them outside the MVC areas then I can access.
I have tried the following:
Why put your scripts in the Areas section? I have an mvc site with an area as well, but I still keep my scripts in the Scripts folder.
My suggestion is to rethink the reason you're organizing your content that way and consider moving all external .js files to the Scripts folder.
<script type="text/javascript" src='<%: ResolveUrl("~/Scripts/jquery/_Roles.js") %>'>
</script>
Have you try
ResolveUrl(
instead of
Url.Content(
?
Stefano
Found an answer in another Stack Overflow question and tweaked it for areas.
Modify /Areas/AreaName/Views/web.config file to enable the webserver to serve JS and CSS files:
<system.web>
<httpHandlers>
<add path="*.js" verb="GET,HEAD" type="System.Web.StaticFileHandler" />
<add path="*.css" verb="GET,HEAD" type="System.Web.StaticFileHandler" />
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!-- other content here -->
</system.web>
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="JavaScript" path="*.js" verb="GET,HEAD" type="System.Web.StaticFileHandler" />
<add name="CSS" path="*.css" verb="GET,HEAD" type="System.Web.StaticFileHandler" />
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
<!-- other content here -->
</system.webServer>
This will allow serving of .js and .css files, and will forbid serving of anything else.