1

My index.html file from MVC application contains below code. All files get loaded into browser but no files from Views folder get loaded. Index.html file, Scripts & Views folders are located at root location.

   <body>
   <div ng-view></div>

        <script src="Scripts/jquery-1.9.1.min.js"></script>
        <script src="Scripts/angular.min.js"></script>
        <script src="Scripts/angular-route.min.js"></script>
        <script src="Scripts/app.js"></script>
        <script src="Views/Authentication/Services.js"></script> -- Error here
        <script src="Views/Authentication/AuthenticationController.js"></script> -- Error here

    </body>

Folder structure

enter image description here

I get below error message when I checked it from chrome devtool.

http://localhost:58348/Views/Authentication/AuthenticationController.js 404 (Not Found)

Even I added js/html handler into web.config but still facing the same issue.

 <add name="JavaScriptHandler" path="*.js" verb="*" preCondition="integratedMode"
            type="System.Web.StaticFileHandler" />

          <add name="HtmlScriptHandler" path="*.html" verb="*" preCondition="integratedMode"
               type="System.Web.StaticFileHandler" />
Sushil Jadhav
  • 2,217
  • 2
  • 19
  • 33

3 Answers3

0

I refereed below post & my problem solved by adding web.config (with js/html handler) into view folder.

Where to put view-specific javascript files in an ASP.NET MVC application?

Community
  • 1
  • 1
Sushil Jadhav
  • 2,217
  • 2
  • 19
  • 33
0

The View might not be able to access the script file due to incorrect Path.

Try,

<script src="~/Views/Authentication/AuthenticationController.js"></script>
Kumar_Vikas
  • 837
  • 7
  • 16
0

First, Determine whether the Scripts/jquery-1.9.1.min.js file is under WEB-INF If it is in this file, change to its same level directory, This may help