To Render Styles in MVC, it's best to use Bundle Config.
In your solution you should have a folder App_Start
If you open BundleConfig.cs
file you will see the Script and Style Bundles.
something like this:
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/STYLE.css"));
The Name of your Bundle above is: "~/Content/css"
.
To include style sheets from this Bundle you include it in the Header/Footer or anywhere in your View.
<head>
@Styles.Render("~/Content/css")
</head>
If you don't want to use the Bundle you can use Url.Content
<head>
<link href="@Url.Content("~/Content/STYLE.css")" rel="stylesheet"/>
</head>
OR you can use the Simple HTML:
<head>
<link href="~/Content/STYLE.css" rel="stylesheet" />
</head>
EDIT:
If you don't have the App_Start Folder you can use this:
Create App_Start Folder
Create a New Class Name it: BundleConfig.cs
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/site.css"));
}
}
- In your Global.asax.cs File add this Line, at the end of Application_Start Method
BundleConfig.RegisterBundles(BundleTable.Bundles);