Switch between http and https for images located in a subdomain

My ASP.NET MVC3 website, www.mysite.com, retrieves images from images.mysite.com. When I do not go to my site and do not use SSL, it works flawlessly. However, when you log in, it gets

Only protected content is displayed.

message in IE9. I understand it. What is the best way to handle URL switching for my images? Should I check if I am currently using SSL, and redirect my images to https://images.mysite.com , otherwise http://images.mysite.com ?

EDIT: This is an e-commerce site, so most of the time the site is viewed without protection. But after logging in, I still need to pull out some of the same images, and, of course, if they return to the regular catalog page, access to the images will be required. I might just have to always use https://images.mysite.com . It just seemed redundant.

+4
source share
3 answers

I believe that the problem only arises when you are on a secure page accessing content via http. Thus, for pages that can be seen on both http and https, it can be as simple as always, using https to get images, regardless of whether you are on http or https.

+1
source

You will always receive this message if you pull content from a site without SSL when viewing via SSL. If your site is mostly SSL protected, just always take out the images from https://images.mysite.com , as you will not get an error if you pull out the SSL content in non--SSL.

Otherwise, you will need to know which pages are available only for viewing via SSL, and which are not, and the link accordingly.

Finally, if you have a website for both, you probably need to look at the HTTPS server to determine if you are on SSL or not, and use this to determine your link (http or https).

+1
source

Have you tried prefix with ~ instead of ../ or /? It worked for me.

+1
source

All Articles