How to use different CSS files for each view

Asked

Viewed 1,071 times

1

I wonder if it is possible to be using CSS files "helpers".

For example, in my ASP.NET project MVC 5, as everyone knows, and default the use of BootStrap, but it would have to create a separate . css file for some views I’ve been creating?

Or, if, necessarily all css programming has to be within the BootStrap.css

  • Yes you have, just set up on blunde and insert into the View.

  • Could you give me a direction? or an explanation about?

  • 1

    Reading here will give you a good explanation. https://msdn.microsoft.com/pt-br/library/dn168847.aspx

1 answer

2


From what I understood of your need, you could create a Section and in the views you needed, point out the necessary css.

For example, have in your Layout @RenderSection("css", required: false). And in the views that implement your layout and use

@section css { <link rel="stylesheet" href="~/caminho/para/css" /> }

It is worth remembering that the Layout file is a cshtml, so I depend on the need you can implement simple logic (although I do not think a good idea).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.