Can I deploy a javascript file in MVC areas?

I have js files inside areas and I cannot access them. When I move them outside of the MVC areas, I can access.

I tried the following:

  • Different names of js files - do not solve the problem.
  • Check if they exist on the server - they do
  • Access file directly from the IIS manager on the server - they will not open and cannot be returned
  • Access to the same files directly from the IIS manager on the server, but when the files are in the script directory, they open in the browser
  • The route checker is used. When I try to access the file, it does not open route debugging and instead just says “404”

It works:

<script src="@Url.Content("~/Scripts/jquery/_Roles.js")" type="text/javascript"></script>

This does not work:

<script src="@Url.Content("~/Areas/Administration/Scripts/Roles/_Roles.js")" type="text/javascript"></script>

- Areas, ?

+5
4

""? mvc , Scripts.

, , , .js Scripts.

-3

.

/Areas/AreaName/Views/web.config , - JS CSS:

<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>

.js .css - .

+1

Try

ResolveUrl(

instead

Url.Content( 

?

Stefano

0
source
<script type="text/javascript" src='<%: ResolveUrl("~/Scripts/jquery/_Roles.js") %>'>
</script>
0
source

All Articles