0

After requiring SSL in a blank ASP.NET MVC application, some of the content is no longer loading. Specifically, at least one stylesheet isn't taking effect as shown in the screenshot below. Nothing appears in the console. I'm assuming that I need to change an HTTP reference to HTTPS somewhere, but it looks like all the script files are included in the project rather than being referenced online.

Any suggestions on how to fix this?

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
superblowncolon
  • 183
  • 1
  • 1
  • 15

1 Answers1

1

This is because the CSS file is being referenced over http:// but the webpage is on https://

It’s known as a ‘Mixed Content’ error

If your site works on both http:// and https:// then there are 2 options

  1. Make the http:// version of your site redirect to the https:// version (recommended)
  2. Make the links to your css file ‘scheme relative’ (also known as ‘protocol relative’) by using just // (two forward slashes) instead of http:// or https://

    e.g. //css/mycssfile.css instead of http://css/mycssfile.css

The scheme relative urls (starting with //) will use the same protocol as the web page.

So if your page is on https:// then //css/mycssfile.css means use https:// to get the css file. The same goes for http://, // means use http:// to get the css file.

  • I did a find and replace for "http:" with "https:". I then cleared my browser's cache and then built the project. The results are the same as the picture in the post. The URL I'm using to access my project begins with https. Any other suggestions? – superblowncolon Sep 04 '18 at 20:11
  • Please check your developer console maybe there is some of error try to solve that. I think you are using some CDN libraries. So please make sure that also will be https not http. – Aman Ahmed Khan Sep 05 '18 at 21:08
  • Aman, per my initial comment, there is nothing in the console. – superblowncolon Sep 05 '18 at 21:09
  • Please check this article " https://stackoverflow.com/questions/15452519/problems-loading-style-sheets-over-https " maybe it will be helpful for you. – Aman Ahmed Khan Sep 05 '18 at 21:16