FortunateDuke
FortunateDuke

Reputation: 1153

CSS not working with IIS7

I have a rails application that I am running with Vista,IIS7 and SQL 2005. For some reason the CSS is not being rendered. The CSS works fine when I use Webrick.

Any ideas how to get CSS working correctly with IIS7. I have uninstalled and reinstalled windows components "Common Http Features" with no luck.

Upvotes: 1

Views: 4957

Answers (8)

Adam Hockemeyer
Adam Hockemeyer

Reputation: 1

You need to enable "static content" when you go to control panel and programs and features and add the features to IIS. For me this was not enabled by default and caused the images/css/js not to display.

Upvotes: 0

Ryan
Ryan

Reputation: 11

In my case, "static content" WAS enabled, and IIS 7 still was not handling css. I tried manually adding a handler for css to no avail. I uninstalled IIS, reinstalled and now it's fine. Sucks when the solution to something like this is a reinstallation, especially something like IIS, but oh well.

Upvotes: 1

user240924
user240924

Reputation:

My Solution was here

You need to add some additional features to IIS from programs and features

Upvotes: 5

John
John

Reputation: 17471

One issue I've run into before was giving each css link tag a 'title' attribute to describe them: some browsers will consider that to mean each css file is meant to be viewed independently of the others (like themes)

If that's the case, remove the title attribute

Upvotes: 0

scunliffe
scunliffe

Reputation: 63580

I would install and run Fiddler2 in IE and see what is comming across on the HTTP Requests.

If the "CSS" isn't working, it is almost guaranteeing that the file isn't linked correctly, or is serving up the wrong content-type headers.

Upvotes: 1

BrynJ
BrynJ

Reputation: 8382

Is your CSS file a linked resource? If not, and it's inline, I find it incredibly strange that your CSS is not rendering - as CSS is only processed by the web browser.

If, as is likely, the CSS is a linked resource then it's a safe bet that is not finding the CSS file - perhaps your web root is configured incorrectly, or maybe your css file is generated and the file header response isn't correct.

Try changing the link, if it's relative make it absolute, otherwise do the reverse. Use something like Firebug or HTTP Fiddler to see if the file is found or not.

Upvotes: 0

eyelidlessness
eyelidlessness

Reputation: 63519

What is the mime-type in the CSS file's header being sent from the server? It needs to be text/css.

Upvotes: 1

Dylan Beattie
Dylan Beattie

Reputation: 54130

Can you use Firebug or something to check that IIS7 is sending the correct MIME type with your stylesheets? Some browsers will ignore CSS unless the server explicitly sends

Content-Type: text/css 

in the HTTP response headers, and with dynamic content or non-standard file extensions you may find that IIS7 isn't configured to do this "out of the box"

Upvotes: 3

Related Questions