5

Newbie here.

I have created an empty MVC project in VS2010 and I'm trying to format my view for authentication. So, I've added this to site.css:

.rez 
{
color: Olive;
}

and this to my View:

@using (Html.BeginForm())
{
<div>
<label class="rez">Username</label><input type="text" name="Username"/>
</div>
<div>
Password<input type="password" name="Password"/>
</div>
<div>
<input type="submit" name="Log"/>
</div>
}

It's not working. I haven't touched routing or bundleconfig. I've configured web.config for authentication. _ViewStart and _Layout are also unchanged.

What am I doing wrong and more importantly how do I debug this issue. I'm using chrome.

Nezreli
  • 1,278
  • 4
  • 16
  • 34

5 Answers5

17

I had the same problem and I found out that the name of the file is "Site.css" and the file which is getting referenced in the BundleConfig.cs is "site.css" with lowercase s. I simply matched the file names and it worked.

edit: another thing to try is open inspect element of your browser, right click on the refresh button and hit empty cache and hard reload.

Fakhar Ahmad Rasul
  • 1,595
  • 1
  • 19
  • 37
4

If you have added the CSS file to your content directory folder ensure that you are calling @Styles.Render("~/Content/css")

Satpal
  • 132,252
  • 13
  • 159
  • 168
Jay
  • 3,012
  • 14
  • 48
  • 99
2

Naming Difference Found in Asp.net MVC 4

case sensitive

the problem is due to the file we're accessing, defined in ~/App_Start/BundleConfig.cs and the file we're applying changes in ~/Content/Site.css

In BundleConfig.cs we have:

bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/site.css"));

but in project directory we have:

~/Content/Site.css

Solution : Make sure to have the same file names.

Fourat
  • 2,366
  • 4
  • 38
  • 53
mzamann1
  • 21
  • 2
0

My site was working fine. I updated the nuget packages and none of the styles would work. Rolling back bootstrap to a previous version fixed it.

whothewho
  • 31
  • 2
0

My site was working fine before being deployed after deployment the site.css was not being loaded, I found out by removing ~ from the ref worked for me from "~/css/site.css" to this "/css/site.css" and works fine now, you can also verify if the ref is within the "<"environment exclude="Development"">" tag.

LaPlagaPR
  • 11
  • 3