Mayank
Mayank

Reputation: 141

MVC CSS on view page (not _layout) not working

I have a problem with MVC4 CSS. i m including a CSS file named registration.css in an another view page named "registerUser.cshtml". This page is like a content page in mvc4 razor. but problem is that CSS is not working.

How can i resolve this. I have also included in BundleConfig.cs as

bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/registration.css"));

But it is also not working. Help me.enter image description here

Upvotes: 1

Views: 20490

Answers (3)

Mayank
Mayank

Reputation: 141

I got my answer. Actually another css file from _Layout.cshtml overwrites the view page css file. when i removed main.css from Viewpage.cshtml, it works fine. Well, Thanks to all, thanks @Exception - u gave me important knowledge.

Upvotes: 1

Kartikeya Khosla
Kartikeya Khosla

Reputation: 18873

If you want a single css file on a page then use this :

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

OR

If you want many css files on Layout Page or at any View Page then make it's bundle and include it in this way:

@Styles.Render("~/Content/css")

You are using @Styles.Render("~/Content/registration.css") which is wrong..try above solution.

Upvotes: 0

Satpal
Satpal

Reputation: 133403

Use

@Styles.Render("~/Content/css")

instead of

@Styles.Render("~/Content/registration.css")

Upvotes: 4

Related Questions