Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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>