CSS does not load, Resource Interpreted as Stylesheet but transferred with MIME type text/html

Asked

Viewed 4,674 times

1

Hello guys I am working on an MVC project but I came across a css error that had never happened to me. By staging CSS the browser returns me a rendering error.

in firefox:

12:08:16.973 The style sheet http://localhost/portfolio/Generic.css was loaded as CSS, although its mime type, "text/html", is not "text/css". 1 portfolio

On google Chrome:

Resource Interpreted as Stylesheet but transferred with MIME type text/html:

Does anyone know what it can be?

  • You are using windows and apache?

  • Maybe at the time of import you have not inferred that it is a "stylesheet".

  • I am using Buntu and apache, I have tested permissions and nothing, I read an article where the guy puts in htaccess the following code : Rewritecond %{SCRIPT_FILENAME} ! -f Rewritecond %{SCRIPT_FILENAME} ! -d tested here and it worked, but I don’t know if it’s more feasible to do this.

  • This code has nothing to do with this, this code is for rewritten urls, tell me you’re using .htaccess, has how to post it in the question?

  • This seems like an error in setting up apache! Do you have access to the /etc/apache2/mime.types file? Do you know if there are any css entries in it?

  • It is probably apache configuration, you said it is MVC, usually in MVC there is a folder for static public content that is configured in apache not to show the private code folders, your css is in a direct location like /var/www/portfolio/generic.css or in another sub-folder as /var/www/portfolio/public/generic.css ?

  • You’re right @Jairocorrea now that I’ve noticed this. Brendol please let me know which MVC framework you’re using.

Show 2 more comments

1 answer

1

Browsers request HTTP for servers. The server then returns an HTTP replay.

Both request and Response consist of a lot of headers and a body (sometimes optional) with some content in it.

If there is a body, then one of the headers is Content-Type, which describes what the body is (is it an HTML document? An image? The content of a form submission? Etc).

When you ask for your Stylesheet, your server is telling the browser that it is an HTML document (Content-Type: text/html) instead of a stylesheet (Content-Type: text/css).

Use the browser’s Network tab to examine the request that is going to the server and its Sponse. Through what appears there you will be able to find out where you are placing the Content-Type for text/html

Browser other questions tagged

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