Homepage images randomly referencing localhost on a live server

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
I noticed that when activating the "Application Initialization" feature of IIS 8.0 and 8.5 the home page images start to reference to localhost, cant be source from where the problems come needs more investigation. For sure is some Code/DLL issue.
8 years ago
I solved this problem.

You must cancel the absolute addresses for pictures in Nop.Service PictureService.cs in GetDefaultPictureUrl() and GetThumbUrl().
8 years ago
aybelanov wrote:
I solved this problem.

You must cancel the absolute addresses for pictures in Nop.Service PictureService.cs in GetDefaultPictureUrl() and GetThumbUrl().


@aybelanov: can you provide a little more details please? You're saying we need to modify the source code and recompile?

I have the same problem on nopCommerce 3.60 hosted on an Azure website.
8 years ago
Hi!

I use Nop 3.5 and Azure Hosting

1. Go to Nop.Service --> Media --> PictureService.cs --> GetThumbUrl()

source code:
//var url = storeLocation + "content/images/thumbs/";

changed code:
var url = "/content/images/thumbs/";

2. Go to Nop.Service --> Media --> PictureService.cs --> GetDefaultPictureUrl()

sorce code:
//string url = (!String.IsNullOrEmpty(storeLocation)
//                 ? storeLocation
//                 : _webHelper.GetStoreLocation())
//                 + "content/images/" + defaultImageFileName;

changed code:
string url = "/content/images/" + defaultImageFileName;
8 years ago
Have a look at my post on this thread over here, it sounds like the same issue: https://www.nopcommerce.com/boards/t/26045/fake-url-injection-in-homepage-nop-300-site.aspx?p=4#152344

Make sure you have your host headers setup correctly in your IIS bindings (though not sure if this applies in Azure)

Edit: Though I think it makes more sense to use relative urls for the image src anyway so your suggested code change is probably better.
8 years ago
I had this problem again in Azure, and it happened after I turned ON the "Always On" feature in the Azure portal for the website.
I turned it off, and the images began to render correctly. Very strange issue as I cant see how its related to this setting either - so could be a co-incidence - but let us know if this also fixes it for you.
6 years ago
@aybelanov code change nearly worked. But in our dev environment we use hosts file entries and subfolders to test multiple stores. Here's modified version that worked for us:

1. Go to Nop.Service --> Media --> PictureService.cs --> GetThumbUrl()

source code:
//var url = storeLocation + "content/images/thumbs/";

changed code:
var url = _webHelper.GetStoreLocation() + "/content/images/thumbs/";

2. Go to Nop.Service --> Media --> PictureService.cs --> GetDefaultPictureUrl()

sorce code:
//string url = (!String.IsNullOrEmpty(storeLocation)
//                 ? storeLocation
//                 : _webHelper.GetStoreLocation())
//                 + "content/images/" + defaultImageFileName;

changed code:
string url = _webHelper.GetStoreLocation() + "/content/images/" + defaultImageFileName;
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.