0

I am unable to access CSS file which is located under MVC AREA section.

Here is the full path of the CSS file.

http://mywebsite/Areas/MVC/Resources/dist/css/custom.css

The path is correct I suppose because JS files and images are being loaded from the same path.

There is also no authentication issue as well.

I tried to debug using firebug and it prints the following error message.

The stylesheet http://mywebsite/Areas/MVC/Resources/dist/css/custom.css was not loaded because its MIME type, "text/html", is not "text/css". Although I have specified the text/css type in the link attribute.

I am referring to the css file as below

link href="~/Areas/MVC/Resources/dist/css/custom.css" rel="stylesheet" type="text/css"

I have also tried giving the absolute path but still no luck.

If we try to open the above link in browser it is opening correctly and showing CSS but it does not load in the application. Also the js resources and images are being loaded in the same folder by using the same path but not the CSS.

17
  • Can you post (some of - maybe just the top 20 lines or so, if it's a big file) your CSS? Your error is suggesting that the code in it might not be formatted correctly as a .css file Commented Jun 24, 2016 at 9:19
  • that error sounds like your server is sending it across as text Commented Jun 24, 2016 at 9:24
  • are you using some kind of handler to serve your css? Commented Jun 24, 2016 at 9:24
  • @GeoffJames I am loading a bootstap file and it is not being loaded as well. In short no css file is working Commented Jun 24, 2016 at 9:55
  • @TheBeardedLlama no I am not using any handler Commented Jun 24, 2016 at 9:56

1 Answer 1

0

As Geoff stated if you could provide a screenshot or a snippet of code along with the error we could give you a more detailed answer.

the only thing I can think of is using the rel attribute and telling your app it's a stylesheet.

<link rel="stylesheet" type="text/css" href="css/style.css"/>

Like above for example. Just to clarify this should be placed in the head of your index.html

Sign up to request clarification or add additional context in comments.

3 Comments

this is the link I am using to refer my CSS files. href="~/Areas/MVC/Resources/dist/css/custom.css" rel="stylesheet" type="text/css"
Are you sure you have you the right path to your file? Navigate to you're desired css file via the terminal then type 'pwd' this will show your path to the file you have just navigated too then use that path in your index.html.
Yes I am sure I have navigate the path return by firebug and my Css code was there. The js files are running from same folder using same path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.