as it seems, my code I use to upload images across multiple instances of sitefinity has a different behavior between environments.
My code does run smoothly on the staging system and creates the images as I like. But when executing the very same code on the base of very same pages (except environments), the url to File of the image is hugely different. Instead of
The prod environment images get the following url (AE being the instance):
How can this be? The https should be the server / domain and http should be https. Why does it act so?
This is the code to upload images:
private void UploadImagesToHeaderAlbum(string imageTitle, string imageFileName, string imageExtension, string albumTitle, Stream imageStream)
LibrariesManager libManager = LibrariesManager.GetManager();
Image image = libManager.GetImages().Where(i => i.Title == imageTitle).FirstOrDefault();
if (image == null)
image = libManager.CreateImage();
Album album = libManager.GetAlbums().Where(i => i.Title == albumTitle).SingleOrDefault();
image.Parent = album;
image.Title = imageTitle;
image.MediaFileUrlName = Regex.Replace(imageFileName.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
image.UrlName = Regex.Replace(imageTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
image.DateCreated = DateTime.UtcNow;
image.LastModified = DateTime.UtcNow;
image.PublicationDate = DateTime.UtcNow;
libManager.Upload(image, imageStream, imageExtension);
EDIT: I just noticed, that this happens with all Images I also manually upload?!
Check your mulsite settings. In the top left click the menu in the admin portal, click manage sites. Look at the properties for the default site and adjust its URL to be the correct URL for where the site is hosted (IIS bindings). This should fix the url or at least narrow that out of the equation.
Hi jread, thanks for giving me some guidance here.
We are not running Multisite for the many instances we have. It's separate pages.
However, the SIteSettings look identical between Test and Production. Same goes for the Bindings in IIS.
I found the issue. If you go into the the Site Settings and the URL, the host name / host url is cut after the first "/. (Administration -> Advanced -> System -> Site Url Settings -> The Host).
I removed everything else in the url there so that there's just the domain. It does work now. Thanks for leading me into that part of the settings.