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

CSS

CSS Style sheet not loading in asp.net mvc using Razor

I have used these lines inside head tag

<link href="~/Content/site.css" rel="stylesheet" type="text/css" /> <link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />

Bootstrap seems to work, but site.css is not loading..I even tried

<link href='@Url.Content("~/Content/site.css")' rel="stylesheet" type="text/css" />

I couldn't find any solution. Where am I going wrong?

2 Answers

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,720 Points

The '~' character is probably the issue. During deployment, you would want to use either a relative path '.' or a complete pathname to ensure the web server can resolve the path.

The '~' character indicates the default home path of the current user in UNIX/Linux/Mac. Thus, it does not translate well to deployment of a website since the '~' may only be understood in the current user's shell login context, but not necessarily a deployment context.

This was written in 1999, but is still true today.

http://jkorpela.fi/tilde.html

Ashley Morley
PLUS
Ashley Morley
Courses Plus Student 6,520 Points

Clearing Your cache works and should update it appropriately hopefully this helps someone out there