ASP MVC import CSS

2019-07-28 16:45发布

问题:

I am new to ASP.NET MVC and I am trying to include a CSS file into my view.

The view is strongly typed and has a List Scaffold Template, it is linked to a master page which itself is linked to a css file and works fine for the master slide but when trying to link the view to a seperate css file I cant as I cannot include tags.

Anybody know how I can resolve this?

回答1:

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


回答2:

You should add a new content place holder in your site.master page in the head tags, i always have one called "HeadContent" which i use for inclusion of scripts and css that i only want on individual pages.