Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# ASP.NET MVC Basics Views View Layouts

Britton Kitchell
.a{fill-rule:evenodd;}techdegree seal-36
Britton Kitchell
Full Stack JavaScript Techdegree Graduate 14,927 Points

Static files not loading, tried moving them to wwwroot

It looks like this series is a bit dated, but I am trying to get through it using .NET 5 and Visual Studio 2019 on a PC. The static files in this lesson do not seem to be getting loaded. I read the other questions that have been posted (most also fairly old) and one user mentioned that the files should be moved to the wwwroot folder, which makes sense. I tried this approach and was unsuccessful however. I also tried using the full path name (instead of the "~", but still no luck.

Here is a link to the project in my GitHub. Any help would be greatly appreciated!

1 Answer

Raul Rodriguez
Raul Rodriguez
12,631 Points

I added the files into the wwwroot folder into their respective directories. And just use the Url.Content method in the layout pages.

<link href="@Url.Content("~/css/site.css")" rel="stylesheet" type="text/css" /> <link href="@Url.Content("~/css/bootstrap.min.css")" rel="stylesheet" type="text/css" /> <script src="@Url.Content("~/Scripts/modernizr-2.6.2.js")"></script>

Josh Holton
Josh Holton
7,403 Points

Was stuck on this. Thank you!