Vivendi Vivendi - 1 month ago 9
C# Question

Reference Dependencies in VS2015 from wwwroot

I have an MVC Web API application created with VS2015 using the new preview

C# 6
.

The project by default comes with a
Dependencies
folder and a
wwwroot
folder. Both of these reside in the root of my project.

In the
wwwroot
I have an
index.html
which is trying to reference
angular.js
which can be found in the
Dependencies/Bower
folder (the actual path name is
$(project_rootDir)/bower_components/
.

So in my
index.html
I simply do:

<script src="../bower_components/angular/angular.js"></script>


When I start
IIS Express
and check what file the
index.html
is trying to load through console then I see it's trying to get it from:

localhost:5000/bower_components/angular/angular.js


But the path should be:

localhost:5000/../bower_components/angular/angular.js


But it seems like it cannot reference JS files from outside of the
wwwroot
folder. So I'm sort of stuck. What can I do? I want to reference the JS files from the
Dependencies
folder from the
wwwroot
folder.

Answer

The files need to be copied to the wwwroot folder. I guess this should be happening automatically but I was having problems with this earlier as well. I followed the steps in this article to copy the relevent files.

http://docs.asp.net/en/latest/client-side/bower.html

The steps wernt exactly as described. Here's what I ended up doing:

  1. Right click on gulpfile.js
  2. Click on "Task Runner Explorer"
  3. Double click on "Tasks -> Copy"
  4. You should now see a "lib" folder in wwwroot with the necessary files.
Comments