user11450087
user11450087

Reputation:

Correct path for linking a style sheet inside MVC

I have a website I built inside atom text editor. I am trying to build the website again in an ASP.NET environment. I am using the MODEL VIEW CONTROLLER design pattern. I have placed some simple styling inside my css file but I don't think my path is correct. I am including a screenshot of my link tag and my codebase/directory. Any help is much appreciated

Upvotes: 0

Views: 1575

Answers (1)

Ajay Sharma
Ajay Sharma

Reputation: 176

Static files, such as HTML, CSS, images, and JavaScript, are assets an ASP.NET Core app serves directly to clients. Some configuration is required to enable serving of these files. The default directory for these files is wwwroot.You should put the css file under this directory. You can also take a look at the Static files Docs if you want to change the default directory for your static files.

Once you put the content folder inside the wwwroot directory. You can use the following code in your view to refer it.

 <link rel="stylesheet" href="~/Content/StyleSheet.css" />

Hope it helps.

Upvotes: 1

Related Questions