DotNetUser
DotNetUser

Reputation: 239

ASP.NET MVC does not catch styles when published

I have an ASP.NET MVC application that works fine when I run it on Visual Studio. But when I publish it, all the styles dont seem to work. Are there any general guidelines on why styles dont work for an MVC application when published because right now I have no clue on what is happenning??

Any ideas and suggestions are appreciated!

Upvotes: 3

Views: 4344

Answers (3)

Jan
Jan

Reputation: 16032

There are many reasons why your css styles might not show up.

  • Caching: Maybe your browser use a cached version of your css file(s). Check with fiddler or clear the browsers cache
  • Wrong relativ path to the css file(s): You should specify relative paths when including css files in your views (use Url.Content("~/...") for getting the right url). This is an issue when you use not the same path on your IIS and your IDE.

But the first check in any cas is to run fiddler and see

  1. Is the browser requesting the right css file(s)
  2. Is the server returning the file or a 404, 304, ... status code

Upvotes: 4

Leniel Maccaferri
Leniel Maccaferri

Reputation: 102378

Get Firebug, inspect the element that should have the style applied and see what CSS is actually present.

Take a look at the CSS Panel and see the CSS files that are being linked (click the down arrow in the master.css as shown in the image below).

enter image description here

Upvotes: 1

Muthu
Muthu

Reputation: 2685

It is possible that you have defined the styles in a new file and have not included the new css file in your project (in Visual Studio .net).

VS.Net does not publish those files which are not part of the project.

Upvotes: 2

Related Questions