Arggghhh Images

Vote:
 

Hello everyone,

I'm relatively new at using images in Episerver 8 (latest version) and I'm becoming totally lost in the way to set it up properly :-(.  And sadly Google is not my friend at all (reading dozens of different implementations)

From what I understand is that you need to create mediatypes for the image. I did so for the type 'ImageFile' (derived from MediaData). Furthermore i created an 'imagefile.cshtml' in Shared/DisplayTemplates folder.

Now if i create a pagetype with a property of type Image it works fine. However, now comes the problems:

- If i drag an image in a contentarea it reads 'The 'ImageFile' cannot be displayed' instead of showing the image

- If i drag the image in a Richtexteditor field, the url shows, not the image

Even worse i got some common problems with images:

- The feature 'open in image editor' is always disabled in the file manager. Als there is no preview visible for the image that is uploaded

- If i select the image button in the richtexteditor it shows the folders but NONE of my uploaded images are showing??

- I work in a development-team and try to use the SQLBlobProvider to share images amongst the developers, it should work by installing nuget package but so far no success.. :-(

Although i understand the power and flexibility of being able to program this, it frustrates me that out of the box images can be so troublesome to use. I hope it's just configuration that solves my problems.

Thanks in advance for anyone helping me!

#123129
Jun 25, 2015 12:34
Vote:
 

Hi!

Can you please provide the code you currently have in ImageFile.cshtml?

#123130
Jun 25, 2015 12:56
Vote:
 

Oh, I just remembered you have to have a Image.cshtml display template as well. This is the simplest example:

@model EPiServer.Core.ContentReference

@if (!ContentReference.IsNullOrEmpty(Model)) 
{
    <img src="@Url.ContentUrl(Model)">
}
#123131
Jun 25, 2015 13:01
Vote:
 

I added the Image.cshtml but to no avail. Do i need a model definition specifically for image as well?

Now i have:

[ContentType(DisplayName = "ImageType", GUID = "45096789-c050-4009-b1f8-b939de7b0298", Description = "")]
    [MediaDescriptor(ExtensionString = "gif,png,jpg,jpeg")]
    

    public class ImageFile : MediaData
    {
        
                [CultureSpecific]
                [Editable(true)]
                [Display(
                    Name = "Description",
                    Description = "Description",
                    GroupName = SystemTabNames.Content,
                    Order = 1)]
                public virtual String Description { get; set; }
         
    }
#123145
Jun 25, 2015 15:21
Vote:
 

The Imagefile.cshtml is

@using EPiServer.Core
@using EPiServer.Web.Mvc.Html
@using EPiServer8.Models.Media

@model ContentReference
@{
    // Get the the MediaData object being rendered
    var currentContent = !ContentReference.IsNullOrEmpty(Model)
                            ? EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<EPiServer.IContentLoader>().Get<MediaData>(Model)
                            : null;
}

@if (currentContent is ImageFile) // Images should be rendered with an image tag and an alt text
{
    var image = (ImageFile)currentContent;

    @*<img src="@UrlResolver.Current.GetUrl(image.ContentLink)">*@

    <img src="@EPiServer.Web.Routing.UrlResolver.Current.GetUrl(image.ContentLink)" alt="@image.Description" widht="100" height="100" />
}
else if (currentContent is ImageData)
{
    <p>bla</p>
}
else if (currentContent != null) // For all other media types, simply render a link
{
    <a href="@EPiServer.Web.Routing.UrlResolver.Current.GetUrl(currentContent.ContentLink)">@currentContent.Name</a>
}
#123146
Jun 25, 2015 15:23
Vote:
 

Hi Ron,

ImageFile should inherit from ImageData, not MediaData.

/Erik

#123147
Jun 25, 2015 15:24
Vote:
 

Wow Erik,

Thank you, that solved part of the problem. I can now select images in the richtexteditor and i see previews, and i can open them in the image editor! Woohoo!

The thing that still doesn't work is to drag an image directly into a contentarea (instead of a block). Should this work?

#123149
Jun 25, 2015 15:34
Vote:
 

For it to work in a contentarea you need a view in one of your partial view folders (standard is ~/Views/Shared) that match the name of the content type (ImageFile.cshtml in your case) and with ImageFile as Model type:

@model Whatever.Your.Namespace.Is.ImageFile

@if (Model != null) 
{
   <img src="@Url.ContentUrl(Model.ContentLink)" alt="@Model.Description">
}
#123150
Edited, Jun 25, 2015 15:42
Vote:
 

And thank you also Matthias! I was not expecting it to put in the /Views/Shared folder. I put it in /Views/Shared/DisplayTemplates

Thanks so much guys for such a rapid response, it helped a bunch!

#123152
Jun 25, 2015 15:58
Vote:
 

If you are wondering about content template (in your case - that you need to place ImageFile inside one of your partial views folders) you may find interesting template model selection process I described in much details here: http://blog.tech-fellow.net/2015/05/30/content-area-under-the-hood-part-2/. Look for "What happens after template is selected?" section.

#123174
Jun 25, 2015 23:36
Vote:
 

Heya

I'm working on a new project with EPiServer 8 project and I'm struggling to get image assets working.. I'm writting a reply on this thread because this has been the closest I've found to demonstrating how to get them working.

I have an ImageFile class:

[ContentType(
DisplayName = "Image File", 
GUID = "bd03e5f7-8e6d-4357-b2c8-fbf093170d98")]
[MediaDescriptor(ExtensionString = "jpg,jpeg,jpe,ico,gif,bmp,png")]
public class ImageFile : ImageData

and I have an image on a content type:

[UIHint(UIHint.Image)]
[Display(
Name = "Main Image",
Description = "Main image for the content",
GroupName = SystemTabNames.Content,
Order = 200)]
public virtual ContentReference MainImage { get; set; }

And an Image.cshtml with:

@model ContentReference
<img src="@Url.ContentUrl(Model)" />

This works well for edit mode (on page editing and previewing) but never works for a visitor on the published page!? I get a missing image and when browsing directly to the image's friendly URL, something like http://mysite.local/globalassets/media/images/test.jpg, I get a page with distinctive EPiServer styling containing the message "Preview is not available for this item."

This is my first EPiServer post v7.5 so probably something I haven't understood yet - what am I missing?

#123556
Jul 08, 2015 12:12
Vote:
 

You should be able to browse ordinary image using its direct friendly url. Do you have any kind of interceptors somewhere regsitered that are handling requests to image files? Are you using image as standalone property and render it somethink like @Html.PropertyFor(m => m.MainImage) or you are referring to case when image is used inside content area?

#123560
Jul 08, 2015 12:40
Vote:
 

Oh, you're right, I forgot to mention I am using @Html.PropertyFor(m => m.CurrentPage.MainImage) to attempt rendering it.

I guess I can confidently say the Image.cshtml is definitely getting rendered since the markup is coming out.. So I can narrow the problem to simply that going to the image's friendly URL doesn't work - it always show's the same EPiServer message "Preview is not available for this item."

Any thoughts on why that would happen?

#123561
Jul 08, 2015 12:57
Vote:
 

What happens when you navigate directly to the image in EPiServer UI from Media pane?

#123562
Jul 08, 2015 13:32
Vote:
 

From the media pane I can double click the ImageFile asset and it'll open up the preview and that renders the image correctly. The only thing interesting to note is that clicking the "Options > Download this file" streams down a corrupted jpg and when I view the file content in a text editor it has the EPiServer styled HTML page markup including the same:

<div class="epieditpaneltitle">
<span class="EP-systemMessage">
Preview is not available for this item.
</span>
</div>

:-/ Thoughts?

#123563
Jul 08, 2015 13:41
Vote:
 

This is strange. If you replicate the same code to AlloyTech. Does it work correctly there? If you enable verbose logging what does log file say when you browse for your image?

#123572
Jul 09, 2015 0:07
Vote:
 

Good ideas, will try that out - BTW do you know where to get the Alloy code these days?

#123575
Jul 09, 2015 1:01
Vote:
 

Just install VS Extension, then create new site and choose "Alloy".

#123578
Jul 09, 2015 6:00
Vote:
 

Firstly, thanks for pointing out where to get Alloy :) I hadn't figured where to get it for a good while now (I'm sure I used to download it directly from world).

So I've enabled verbose logging and tested three scenarios: loading the image directly using the file URL for visitors (friendly), then the file URL that the on-page editor does, and finally using an image from the Alloy site.

1) Browsing to the file URL for visitors (friendly) - this fails to load the image (it results in the "Preview is not available for this item." page) - here is the epi log output:

2015-07-09 11:16:22,034 [20] DEBUG EPiServer.Security.VirtualRoleAuthorizationSession: The current principal does not have any claims identities added to the Identities collection, one will be added (actual type=System.Web.Security.RolePrincipal)
2015-07-09 11:16:22,043 [20] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/media/images/netpagedefinitionsave_stringtruncationissue.jpg' since it doesn't start with '~/EPiServer/EPiServer.Commerce.Shell/8.11.0.611'
2015-07-09 11:16:22,059 [20] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/media/images/netpagedefinitionsave_stringtruncationissue.jpg' since it doesn't start with '~/EPiServer/CMS/8.1.0.0'
2015-07-09 11:16:22,073 [20] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/media/images/netpagedefinitionsave_stringtruncationissue.jpg' since it doesn't start with '~/EPiServer/Shell/8.1.0.0'
2015-07-09 11:16:22,080 [20] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/media/images/netpagedefinitionsave_stringtruncationissue.jpg' since it doesn't start with '~/EPiServer/EPiServer.Packaging.UI/3.2.1.0'
2015-07-09 11:16:22,088 [20] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/media/images/netpagedefinitionsave_stringtruncationissue.jpg' since it doesn't start with '~/EPiServer/EPiServer.Commerce.Shell.ManagerIntegration/8.11.0.611'
2015-07-09 11:16:22,099 [20] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/media/images/netpagedefinitionsave_stringtruncationissue.jpg' since it doesn't start with '~/EPiServer/Commerce/8.11.0.611'
2015-07-09 11:16:22,120 [20] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/media/images/netpagedefinitionsave_stringtruncationissue.jpg' since it doesn't start with '~/EPiServer/Find'
2015-07-09 11:16:22,132 [20] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/media/images/netpagedefinitionsave_stringtruncationissue.jpg' since it doesn't start with '~/EPiServer/EPiServer.Commerce.UI'
2015-07-09 11:16:22,142 [20] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/media/images/netpagedefinitionsave_stringtruncationissue.jpg' since it doesn't start with '~/modules'
2015-07-09 11:16:22,149 [20] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/media/images/netpagedefinitionsave_stringtruncationissue.jpg' since it doesn't start with '~/episerver'
2015-07-09 11:16:22,161 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:22,174 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:22,191 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:22,199 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, CacheManager.Get returned object of type EPiServer.DataAbstraction.LanguageBranchCollection[] for key
2015-07-09 11:16:22,208 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, returning object of type TObject
2015-07-09 11:16:22,217 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, returning an object of type TObject
2015-07-09 11:16:22,225 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:22,239 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:22,247 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:22,261 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, CacheManager.Get returned object of type EPiServer.DataAbstraction.LanguageBranchCollection[] for key
2015-07-09 11:16:22,283 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, returning object of type TObject
2015-07-09 11:16:22,303 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, returning an object of type TObject
2015-07-09 11:16:22,319 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:6:globalassets
2015-07-09 11:16:22,336 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:6:globalassets
2015-07-09 11:16:22,359 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:6:globalassets, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:22,377 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:6:globalassets, retry 1, CacheManager.Get returned object of type System.Collections.ObjectModel.ReadOnlyCollection`1[[EPiServer.Core.MatchingSegmentResult, EPiServer, Version=8.2.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7]] for key
2015-07-09 11:16:22,408 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:6:globalassets, retry 1, returning object of type TObject
2015-07-09 11:16:22,424 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:6:globalassets, returning an object of type TObject
2015-07-09 11:16:22,434 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:6:globalassets
2015-07-09 11:16:22,457 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:6:globalassets
2015-07-09 11:16:22,466 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:6:globalassets, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:22,481 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:6:globalassets, retry 1, CacheManager.Get returned object of type System.Collections.ObjectModel.ReadOnlyCollection`1[[EPiServer.Core.MatchingSegmentResult, EPiServer, Version=8.2.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7]] for key
2015-07-09 11:16:22,497 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:6:globalassets, retry 1, returning object of type TObject
2015-07-09 11:16:22,510 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:6:globalassets, returning an object of type TObject
2015-07-09 11:16:22,517 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'Get' with parameter values: 6
2015-07-09 11:16:22,530 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'GetClosestSetting' with parameter values: 6
2015-07-09 11:16:22,537 [20] DEBUG EPiServer.Web.Routing.Segments.NodeSegment: Url 'http://buybook.local/globalassets/media/images/netpagedefinitionsave_stringtruncationissue.jpg' was routed to content with id '6' and language was set to ''
2015-07-09 11:16:22,546 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:22,553 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:22,563 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:22,570 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, CacheManager.Get returned object of type EPiServer.DataAbstraction.LanguageBranchCollection[] for key
2015-07-09 11:16:22,579 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, returning object of type TObject
2015-07-09 11:16:22,586 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, returning an object of type TObject
2015-07-09 11:16:22,596 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:22,603 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:22,612 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:22,620 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, CacheManager.Get returned object of type EPiServer.DataAbstraction.LanguageBranchCollection[] for key
2015-07-09 11:16:22,635 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, returning object of type TObject
2015-07-09 11:16:22,646 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, returning an object of type TObject
2015-07-09 11:16:22,658 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:22,668 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:22,682 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:22,691 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, CacheManager.Get returned object of type EPiServer.DataAbstraction.LanguageBranchCollection[] for key
2015-07-09 11:16:22,700 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, returning object of type TObject
2015-07-09 11:16:22,713 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, returning an object of type TObject
2015-07-09 11:16:22,723 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:22,731 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:22,739 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:22,746 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, CacheManager.Get returned object of type EPiServer.DataAbstraction.LanguageBranchCollection[] for key
2015-07-09 11:16:22,753 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, returning object of type TObject
2015-07-09 11:16:22,768 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, returning an object of type TObject
2015-07-09 11:16:22,783 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:3:media
2015-07-09 11:16:22,799 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:3:media
2015-07-09 11:16:22,834 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:3:media, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:22,883 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:3:media, retry 1, CacheManager.Get returned object of type System.Collections.ObjectModel.ReadOnlyCollection`1[[EPiServer.Core.MatchingSegmentResult, EPiServer, Version=8.2.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7]] for key
2015-07-09 11:16:22,891 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:3:media, retry 1, returning object of type TObject
2015-07-09 11:16:22,901 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:3:media, returning an object of type TObject
2015-07-09 11:16:22,927 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'Get' with parameter values: 7
2015-07-09 11:16:22,948 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'GetClosestSetting' with parameter values: 7
2015-07-09 11:16:22,969 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:7:images
2015-07-09 11:16:22,984 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:7:images
2015-07-09 11:16:22,998 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:7:images, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:23,014 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:7:images, retry 1, CacheManager.Get returned object of type System.Collections.ObjectModel.ReadOnlyCollection`1[[EPiServer.Core.MatchingSegmentResult, EPiServer, Version=8.2.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7]] for key
2015-07-09 11:16:23,049 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:7:images, retry 1, returning object of type TObject
2015-07-09 11:16:23,067 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:7:images, returning an object of type TObject
2015-07-09 11:16:23,097 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'Get' with parameter values: 8
2015-07-09 11:16:23,136 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'GetClosestSetting' with parameter values: 8
2015-07-09 11:16:23,161 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:8:netpagedefinitionsave_stringtruncationissue.jpg
2015-07-09 11:16:23,215 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:8:netpagedefinitionsave_stringtruncationissue.jpg
2015-07-09 11:16:23,233 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:8:netpagedefinitionsave_stringtruncationissue.jpg, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:23,269 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:8:netpagedefinitionsave_stringtruncationissue.jpg, retry 1, CacheManager.Get returned object of type System.Collections.ObjectModel.ReadOnlyCollection`1[[EPiServer.Core.MatchingSegmentResult, EPiServer, Version=8.2.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7]] for key
2015-07-09 11:16:23,297 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:8:netpagedefinitionsave_stringtruncationissue.jpg, retry 1, returning object of type TObject
2015-07-09 11:16:23,315 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EPSegmentData:8:netpagedefinitionsave_stringtruncationissue.jpg, returning an object of type TObject
2015-07-09 11:16:23,331 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'Get' with parameter values: 1816
2015-07-09 11:16:23,347 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'GetClosestSetting' with parameter values: 1816
2015-07-09 11:16:23,366 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'Get' with parameter values: 1816
2015-07-09 11:16:23,381 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'GetClosestSetting' with parameter values: 1816
2015-07-09 11:16:23,400 [20] DEBUG EPiServer.Web.Routing.Segments.NodeSegment: Url 'http://buybook.local/globalassets/media/images/netpagedefinitionsave_stringtruncationissue.jpg' was routed to content with id '1816' and language was set to ''
2015-07-09 11:16:23,418 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:23,436 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:23,450 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:23,464 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, CacheManager.Get returned object of type EPiServer.DataAbstraction.LanguageBranchCollection[] for key
2015-07-09 11:16:23,483 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, returning object of type TObject
2015-07-09 11:16:23,495 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, returning an object of type TObject
2015-07-09 11:16:23,504 [20] DEBUG EPiServer.Web.TemplateResolver: ImageFile: Selected EPiServer.Cms.Shell.UI.Controllers.Preview.DefaultMediaPreviewController. (tag='', channel='', category='MvcController')
2015-07-09 11:16:23,520 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:23,542 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:16:23,558 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, calling CacheManager.Get for key
2015-07-09 11:16:23,566 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, CacheManager.Get returned object of type EPiServer.DataAbstraction.LanguageBranchCollection[] for key
2015-07-09 11:16:23,584 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, returning object of type TObject
2015-07-09 11:16:23,608 [20] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, returning an object of type TObject
2015-07-09 11:16:23,619 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'Get' with parameter values: 1816
2015-07-09 11:16:23,641 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'GetClosestSetting' with parameter values: 1816
2015-07-09 11:16:23,651 [20] DEBUG EPiServer.Web.TemplateResolver: ImageFile: Selected EPiServer.Cms.Shell.UI.Controllers.Preview.DefaultMediaPreviewController. (tag='', channel='', category='Page')
2015-07-09 11:16:23,688 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'Get' with parameter values: 1816
2015-07-09 11:16:23,704 [20] DEBUG EPiServer.Commerce.Catalog.CatalogContentLanguageSettingsHandler: Calling 'GetClosestSetting' with parameter values: 1816

2) Browsing to the file URL that the on-page editor does (this works):

2015-07-09 11:41:01,925 [32] DEBUG EPiServer.Security.VirtualRoleAuthorizationSession: The current principal does not have any claims identities added to the Identities collection, one will be added (actual type=System.Web.Security.RolePrincipal)
2015-07-09 11:41:01,938 [32] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/EPiServer/CMS/Content/globalassets/en/media/images/netpagedefinitionsave_stringtruncationissue.jpg,,1816' since it doesn't start with '~/EPiServer/EPiServer.Packaging.UI/3.2.1.0'
2015-07-09 11:41:01,948 [32] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/EPiServer/CMS/Content/globalassets/en/media/images/netpagedefinitionsave_stringtruncationissue.jpg,,1816' since it doesn't start with '~/EPiServer/Commerce/Shell/8.11.0.611'
2015-07-09 11:41:01,951 [32] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/EPiServer/CMS/Content/globalassets/en/media/images/netpagedefinitionsave_stringtruncationissue.jpg,,1816' since it doesn't start with '~/EPiServer/CMS/8.1.0.0'
2015-07-09 11:41:01,953 [32] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/EPiServer/CMS/Content/globalassets/en/media/images/netpagedefinitionsave_stringtruncationissue.jpg,,1816' since it doesn't start with '~/EPiServer/Commerce/Manager/8.11.0.611'
2015-07-09 11:41:01,955 [32] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/EPiServer/CMS/Content/globalassets/en/media/images/netpagedefinitionsave_stringtruncationissue.jpg,,1816' since it doesn't start with '~/EPiServer/Shell/8.1.0.0'
2015-07-09 11:41:01,959 [32] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/EPiServer/CMS/Content/globalassets/en/media/images/netpagedefinitionsave_stringtruncationissue.jpg,,1816' since it doesn't start with '~/EPiServer/EPiServer.Commerce.UI'
2015-07-09 11:41:01,964 [32] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/EPiServer/CMS/Content/globalassets/en/media/images/netpagedefinitionsave_stringtruncationissue.jpg,,1816' since it doesn't start with '~/EPiServer/Find'
2015-07-09 11:41:01,966 [32] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/EPiServer/CMS/Content/globalassets/en/media/images/netpagedefinitionsave_stringtruncationissue.jpg,,1816' since it doesn't start with '~/EPiServer/Commerce/8.11.0.611'
2015-07-09 11:41:01,968 [32] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: None of the '8' route collection for path '~/episerver' wants to handle the path: ~/EPiServer/CMS/Content/globalassets/en/media/images/netpagedefinitionsave_stringtruncationissue.jpg,,1816
2015-07-09 11:41:01,970 [32] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/EPiServer/CMS/Content/globalassets/en/media/images/netpagedefinitionsave_stringtruncationissue.jpg,,1816' since it doesn't start with '~/modules'
2015-07-09 11:41:01,972 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:41:01,974 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:41:01,977 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, calling CacheManager.Get for key
2015-07-09 11:41:01,979 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, CacheManager.Get returned object of type EPiServer.DataAbstraction.LanguageBranchCollection[] for key
2015-07-09 11:41:01,981 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, returning object of type TObject
2015-07-09 11:41:01,983 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, returning an object of type TObject
2015-07-09 11:41:01,985 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:41:01,987 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:41:01,989 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, calling CacheManager.Get for key
2015-07-09 11:41:01,991 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, CacheManager.Get returned object of type EPiServer.DataAbstraction.LanguageBranchCollection[] for key
2015-07-09 11:41:01,995 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, returning object of type TObject
2015-07-09 11:41:01,998 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, returning an object of type TObject
2015-07-09 11:41:02,001 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825
2015-07-09 11:41:02,003 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825
2015-07-09 11:41:02,005 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, calling CacheManager.Get for key
2015-07-09 11:41:02,008 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, CacheManager.Get returned object of type Navico.B2B.Buybook.Web.Models.Files.ImageFile for key
2015-07-09 11:41:02,011 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, returning object of type TObject
2015-07-09 11:41:02,014 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, returning an object of type TObject
2015-07-09 11:41:02,016 [32] INFO EPiServer.Core.ContentProvider: ContentLink=1816_1825, returning ContentReference object
2015-07-09 11:41:02,018 [32] DEBUG EPiServer.Web.Routing.Segments.NodeSegment: Url 'http://buybook.local/EPiServer/CMS/Content/globalassets/en/media/images/netpagedefinitionsave_stringtruncationissue.jpg,,1816?epieditmode=False' was routed to content with id '1816_1825' and language was set to ''
2015-07-09 11:41:02,020 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:41:02,022 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:41:02,024 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, calling CacheManager.Get for key
2015-07-09 11:41:02,027 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, CacheManager.Get returned object of type EPiServer.DataAbstraction.LanguageBranchCollection[] for key
2015-07-09 11:41:02,031 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, returning object of type TObject
2015-07-09 11:41:02,033 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, returning an object of type TObject
2015-07-09 11:41:02,035 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825
2015-07-09 11:41:02,037 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825
2015-07-09 11:41:02,039 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, calling CacheManager.Get for key
2015-07-09 11:41:02,044 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, CacheManager.Get returned object of type Navico.B2B.Buybook.Web.Models.Files.ImageFile for key
2015-07-09 11:41:02,049 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, returning object of type TObject
2015-07-09 11:41:02,051 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, returning an object of type TObject
2015-07-09 11:41:02,053 [32] INFO EPiServer.Core.ContentProvider: ContentLink=1816_1825, returning ContentReference object
2015-07-09 11:41:02,056 [32] DEBUG EPiServer.Web.TemplateResolver: ImageFile: Selected EPiServer.Cms.Shell.UI.Controllers.Preview.DefaultMediaPreviewController. (tag='Preview', channel='', category='MvcController')
2015-07-09 11:41:02,059 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:41:02,062 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch
2015-07-09 11:41:02,065 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, calling CacheManager.Get for key
2015-07-09 11:41:02,067 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, CacheManager.Get returned object of type EPiServer.DataAbstraction.LanguageBranchCollection[] for key
2015-07-09 11:41:02,069 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, retry 1, returning object of type TObject
2015-07-09 11:41:02,071 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EP:LanguageBranch, returning an object of type TObject
2015-07-09 11:41:02,073 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825
2015-07-09 11:41:02,076 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825
2015-07-09 11:41:02,080 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, calling CacheManager.Get for key
2015-07-09 11:41:02,083 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, CacheManager.Get returned object of type Navico.B2B.Buybook.Web.Models.Files.ImageFile for key
2015-07-09 11:41:02,085 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, returning object of type TObject
2015-07-09 11:41:02,087 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, returning an object of type TObject
2015-07-09 11:41:02,089 [32] INFO EPiServer.Core.ContentProvider: ContentLink=1816_1825, returning ContentReference object
2015-07-09 11:41:02,092 [32] DEBUG EPiServer.Web.TemplateResolver: ImageFile: Selected EPiServer.Cms.Shell.UI.Controllers.Preview.ImagePreviewHandler. (tag='Preview', channel='', category='Page')
2015-07-09 11:41:02,096 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825
2015-07-09 11:41:02,098 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825
2015-07-09 11:41:02,100 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, calling CacheManager.Get for key
2015-07-09 11:41:02,102 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, CacheManager.Get returned object of type Navico.B2B.Buybook.Web.Models.Files.ImageFile for key
2015-07-09 11:41:02,104 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, returning object of type TObject
2015-07-09 11:41:02,106 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, returning an object of type TObject
2015-07-09 11:41:02,109 [32] INFO EPiServer.Core.ContentProvider: ContentLink=1816_1825, returning ContentReference object
2015-07-09 11:41:02,114 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825
2015-07-09 11:41:02,116 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825
2015-07-09 11:41:02,119 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, calling CacheManager.Get for key
2015-07-09 11:41:02,121 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, CacheManager.Get returned object of type Navico.B2B.Buybook.Web.Models.Files.ImageFile for key
2015-07-09 11:41:02,123 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, retry 1, returning object of type TObject
2015-07-09 11:41:02,126 [32] INFO EPiServer.Core.OptimisticCache: cacheKey=EPContentVersion:1816_1825, returning an object of type TObject
2015-07-09 11:41:02,129 [32] INFO EPiServer.Core.ContentProvider: ContentLink=1816_1825, returning ContentReference object

3) Finally, this is probably how it should be, using a standard image file URL on the alloy site:

2015-07-09 16:14:05,850 [12] DEBUG EPiServer.Security.VirtualRoleAuthorizationSession: The current principal does not have any claims identities added to the Identities collection, one will be added (actual type=System.Web.Security.RolePrincipal)
2015-07-09 16:14:05,866 [12] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/alloy-meet/alloymeet.png' since it doesn't start with '~/EPiServer/CMS/8.2.2.0'
2015-07-09 16:14:05,879 [12] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/alloy-meet/alloymeet.png' since it doesn't start with '~/EPiServer/Shell/8.2.2.0'
2015-07-09 16:14:05,884 [12] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/alloy-meet/alloymeet.png' since it doesn't start with '~/EPiServer/EPiServer.Packaging.UI/3.2.2.0'
2015-07-09 16:14:05,889 [12] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/alloy-meet/alloymeet.png' since it doesn't start with '~/episerver'
2015-07-09 16:14:05,893 [12] DEBUG EPiServer.Shell.Web.Routing.ModuleRouteCollection: Not routing '~/globalassets/alloy-meet/alloymeet.png' since it doesn't start with '~/modules'
2015-07-09 16:14:05,922 [12] DEBUG EPiServer.Web.Routing.Segments.NodeSegment: Url 'http://localhost:55979/globalassets/alloy-meet/alloymeet.png' was routed to content with id '87' and language was set to ''
2015-07-09 16:14:05,930 [12] DEBUG EPiServer.Web.TemplateResolver: ImageFile: Selected . (tag='', channel='web', category='MvcController')
2015-07-09 16:14:05,935 [12] DEBUG EPiServer.Web.TemplateResolver: ImageFile: Selected EPiServer.Web.ContentMediaHttpHandler. (tag='', channel='web', category='Page')

A few interesting differences I've noticed between logs are:

- #1 never seems to identify the content being an ImageFile

- #1 template selection never ends up selecting EPiServer.Cms.Shell.UI.Controllers.Preview.ImagePreviewHandler

- #3 (alloy) is very brief and its template selection quickly chooses EPiServer.Web.ContentMediaHttpHandler

But does anyone have any thoughts what we may have changed that might have compromised image handling?

#123580
Jul 09, 2015 8:28
Vote:
 

This is the problem:

2015-07-09 11:16:23,504

Don't like that there is a Commerce handler in between. That may mess around routes (some example here).

Can you dump registered templates for ImageFile?

var repo = ServiceLocator.Current.GetInstance<TemplateModelRepository>();
var models = repo.List(typeof(ImageFile));

Also, can you check which guy is responsible for your route?

Subscribe to event somewhere (once). Bet place is initializable module:

ContentRoute.RoutedContent += ContentRoute_RoutedContent;

And then inspect this property:

private void ContentRoute_RoutedContent(object sender, RoutingEventArgs e)
{
    var route = e.RoutingSegmentContext.RouteData;
}
#123585
Jul 09, 2015 9:35
Vote:
 

Hi Valdis

Thanks for your tips and assistance - I've run these with the debugger.

The repo.List(typeof(ImageFile)) got the following in the debug watch:

models	Count = 6	System.Collections.Generic.IEnumerable<EPiServer.DataAbstraction.TemplateModel> {System.Collections.ObjectModel.ReadOnlyCollection<EPiServer.DataAbstraction.TemplateModel>}

	[0]	{EPiServer.DataAbstraction.TemplateModel}	EPiServer.DataAbstraction.TemplateModel
	AvailableWithoutTag	true	bool
	Default	false	bool
	Description	null	string
	DisplayName	null	string
	Inherit	false	bool
	Inherited	false	bool
	IsReadOnly	false	bool
	Name	"ImageFile"	string
	Path	null	string
	Tags	null	string[]
	TemplateType	null	System.Type
	TemplateTypeCategory	MvcPartialView	EPiServer.Framework.Web.TemplateTypeCategories

	[1]	{EPiServer.DataAbstraction.TemplateModel}	EPiServer.DataAbstraction.TemplateModel
	AvailableWithoutTag	false	bool
	Default	false	bool
	Description	null	string
	DisplayName	null	string
	Inherit	true	bool
	Inherited	false	bool
	IsReadOnly	false	bool
	Name	"ImageFileController"	string
	Path	null	string
	Tags	{string[1]}	string[]
	TemplateType	{Name = "ImageFileController" FullName = "Navico.B2B.Buybook.Web.Controllers.ImageFileController"}	System.Type {System.RuntimeType}
	TemplateTypeCategory	MvcPartialController	EPiServer.Framework.Web.TemplateTypeCategories

	[2]	{EPiServer.DataAbstraction.TemplateModel}	EPiServer.DataAbstraction.TemplateModel
	AvailableWithoutTag	false	bool
	Default	false	bool
	Description	null	string
	DisplayName	null	string
	Inherit	true	bool
	Inherited	true	bool
	IsReadOnly	false	bool
	Name	"ImagePreviewHandler"	string
	Path	null	string
	Tags	{string[1]}	string[]
	TemplateType	{Name = "ImagePreviewHandler" FullName = "EPiServer.Cms.Shell.UI.Controllers.Preview.ImagePreviewHandler"}	System.Type {System.RuntimeType}
	TemplateTypeCategory	HttpHandler	EPiServer.Framework.Web.TemplateTypeCategories

	[3]	{EPiServer.DataAbstraction.TemplateModel}	EPiServer.DataAbstraction.TemplateModel
	AvailableWithoutTag	false	bool
	Default	false	bool
	Description	null	string
	DisplayName	null	string
	Inherit	true	bool
	Inherited	true	bool
	IsReadOnly	false	bool
	Name	"ImageEditController"	string
	Path	null	string
	Tags	{string[1]}	string[]
	TemplateType	{Name = "ImageEditController" FullName = "EPiServer.Cms.Shell.UI.Controllers.Preview.ImageEditController"}	System.Type {System.RuntimeType}
	TemplateTypeCategory	MvcController	EPiServer.Framework.Web.TemplateTypeCategories

	[4]	{EPiServer.DataAbstraction.TemplateModel}	EPiServer.DataAbstraction.TemplateModel
	AvailableWithoutTag	false	bool
	Default	false	bool
	Description	null	string
	DisplayName	null	string
	Inherit	true	bool
	Inherited	true	bool
	IsReadOnly	false	bool
	Name	"DefaultMediaPreviewController"	string
	Path	null	string
	Tags	{string[2]}	string[]
	TemplateType	{Name = "DefaultMediaPreviewController" FullName = "EPiServer.Cms.Shell.UI.Controllers.Preview.DefaultMediaPreviewController"}	System.Type {System.RuntimeType}
	TemplateTypeCategory	MvcController	EPiServer.Framework.Web.TemplateTypeCategories

	[5]	{EPiServer.DataAbstraction.TemplateModel}	EPiServer.DataAbstraction.TemplateModel
	AvailableWithoutTag	true	bool
	Default	false	bool
	Description	null	string
	DisplayName	null	string
	Inherit	true	bool
	Inherited	true	bool
	IsReadOnly	false	bool
	Name	"ContentMediaHttpHandler"	string
	Path	null	string
	Tags	null	string[]
	TemplateType	{Name = "ContentMediaHttpHandler" FullName = "EPiServer.Web.ContentMediaHttpHandler"}	System.Type {System.RuntimeType}
	TemplateTypeCategory	HttpHandler	EPiServer.Framework.Web.TemplateTypeCategories

^Please note that the second template model "Navico.B2B.Buybook.Web.Controllers.ImageFileController" is a new controller I've been testing with (and hasn't helped thus far)

And as for the e.RoutingSegmentContext.RouteData, here's the debug snapshot (I'm not sure what the most useful information in it would be so let me know if you'd like different info):

e.RoutingSegmentContext.RouteData	{System.Web.Routing.RouteData}	System.Web.Routing.RouteData
	DataTokens	{System.Web.Routing.RouteValueDictionary}	System.Web.Routing.RouteValueDictionary
	Route	{EPiServer.Web.Routing.ContentRoute}	System.Web.Routing.RouteBase {EPiServer.Web.Routing.ContentRoute}
		[EPiServer.Web.Routing.ContentRoute]	{EPiServer.Web.Routing.ContentRoute}	EPiServer.Web.Routing.ContentRoute
			base	{EPiServer.Web.Routing.ContentRoute}	System.Web.Routing.Route {EPiServer.Web.Routing.ContentRoute}
			Name	"Media_Global"	string
			StrictLanguageRoutingResolver	{Method = {Boolean <MapContentRoute>b__1()}}	System.Func<bool>
			Url	'((EPiServer.Web.Routing.ContentRoute)(e.RoutingSegmentContext.RouteData.Route)).Url' threw an exception of type 'System.NotImplementedException'	string {System.NotImplementedException}
			Static members
		RouteExistingFiles	true	bool
	RouteHandler	{EPiServer.Web.Routing.MultiplexingRouteHandler}	System.Web.Routing.IRouteHandler {EPiServer.Web.Routing.MultiplexingRouteHandler}
	Values	{System.Web.Routing.RouteValueDictionary}	System.Web.Routing.RouteValueDictionary


Interesting info, but not sure I know what to make of it - your thoughts?

#123598
Edited, Jul 09, 2015 14:46
Vote:
 

Oh, and if it helps, I've just gone and done the same debugging on the Alloy site with the working routing for reference.

Here's the Template models:

models	Count = 6	System.Collections.Generic.IEnumerable<EPiServer.DataAbstraction.TemplateModel> {System.Collections.ObjectModel.ReadOnlyCollection<EPiServer.DataAbstraction.TemplateModel>}

	[0]	{EPiServer.DataAbstraction.TemplateModel}	EPiServer.DataAbstraction.TemplateModel
	AvailableWithoutTag	true	bool
	Default	false	bool
	Description	null	string
	DisplayName	null	string
	Inherit	true	bool
	Inherited	false	bool
	IsReadOnly	false	bool
	Name	"ImageFileController"	string
	Path	null	string
	Tags	null	string[]
	TemplateType	{Name = "ImageFileController" FullName = "EPiServerSite1.Controllers.ImageFileController"}	System.Type {System.RuntimeType}
	TemplateTypeCategory	MvcPartialController	EPiServer.Framework.Web.TemplateTypeCategories

	[1]	{EPiServer.DataAbstraction.TemplateModel}	EPiServer.DataAbstraction.TemplateModel
	AvailableWithoutTag	false	bool
	Default	false	bool
	Description	null	string
	DisplayName	null	string
	Inherit	true	bool
	Inherited	true	bool
	IsReadOnly	false	bool
	Name	"ImagePreviewHandler"	string
	Path	null	string
	Tags	{string[1]}	string[]
	TemplateType	{Name = "ImagePreviewHandler" FullName = "EPiServer.Cms.Shell.UI.Controllers.Preview.ImagePreviewHandler"}	System.Type {System.RuntimeType}
	TemplateTypeCategory	HttpHandler	EPiServer.Framework.Web.TemplateTypeCategories

	[2]	{EPiServer.DataAbstraction.TemplateModel}	EPiServer.DataAbstraction.TemplateModel
	AvailableWithoutTag	false	bool
	Default	false	bool
	Description	null	string
	DisplayName	null	string
	Inherit	true	bool
	Inherited	true	bool
	IsReadOnly	false	bool
	Name	"ImageEditController"	string
	Path	null	string
	Tags	{string[1]}	string[]
	TemplateType	{Name = "ImageEditController" FullName = "EPiServer.Cms.Shell.UI.Controllers.Preview.ImageEditController"}	System.Type {System.RuntimeType}
	TemplateTypeCategory	MvcController	EPiServer.Framework.Web.TemplateTypeCategories

	[3]	{EPiServer.DataAbstraction.TemplateModel}	EPiServer.DataAbstraction.TemplateModel
	AvailableWithoutTag	true	bool
	Default	false	bool
	Description	null	string
	DisplayName	null	string
	Inherit	true	bool
	Inherited	true	bool
	IsReadOnly	false	bool
	Name	"ContentMediaHttpHandler"	string
	Path	null	string
	Tags	null	string[]
	TemplateType	{Name = "ContentMediaHttpHandler" FullName = "EPiServer.Web.ContentMediaHttpHandler"}	System.Type {System.RuntimeType}
	TemplateTypeCategory	HttpHandler	EPiServer.Framework.Web.TemplateTypeCategories

	[4]	{EPiServer.DataAbstraction.TemplateModel}	EPiServer.DataAbstraction.TemplateModel
	AvailableWithoutTag	false	bool
	Default	false	bool
	Description	null	string
	DisplayName	null	string
	Inherit	true	bool
	Inherited	true	bool
	IsReadOnly	false	bool
	Name	"DefaultMediaPreviewController"	string
	Path	null	string
	Tags	{string[2]}	string[]
	TemplateType	{Name = "DefaultMediaPreviewController" FullName = "EPiServer.Cms.Shell.UI.Controllers.Preview.DefaultMediaPreviewController"}	System.Type {System.RuntimeType}
	TemplateTypeCategory	MvcController	EPiServer.Framework.Web.TemplateTypeCategories

	[5]	{EPiServer.DataAbstraction.TemplateModel}	EPiServer.DataAbstraction.TemplateModel
	AvailableWithoutTag	false	bool
	Default	false	bool
	Description	null	string
	DisplayName	null	string
	Inherit	true	bool
	Inherited	true	bool
	IsReadOnly	false	bool
	Name	"NoRendererMessage"	string
	Path	"~/Views/Shared/Blocks/NoRenderer.cshtml"	string
	Tags	{string[1]}	string[]
	TemplateType	{Name = "PartialViewRenderTemplate`1" FullName = "EPiServer.Web.Mvc.PartialViewRenderTemplate`1[[EPiServer.Core.IContentData, EPiServer, Version=8.8.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7]]"}	System.Type {System.RuntimeType}
	TemplateTypeCategory	MvcPartialView	EPiServer.Framework.Web.TemplateTypeCategories

And here's the e.RoutingSegmentContext.RouteData (which, at least what I inspected, is identical):

e.RoutingSegmentContext.RouteData	{System.Web.Routing.RouteData}	System.Web.Routing.RouteData
	DataTokens	{System.Web.Routing.RouteValueDictionary}	System.Web.Routing.RouteValueDictionary
	Route	{EPiServer.Web.Routing.ContentRoute}	System.Web.Routing.RouteBase {EPiServer.Web.Routing.ContentRoute}
		[EPiServer.Web.Routing.ContentRoute]	{EPiServer.Web.Routing.ContentRoute}	EPiServer.Web.Routing.ContentRoute
			base	{EPiServer.Web.Routing.ContentRoute}	System.Web.Routing.Route {EPiServer.Web.Routing.ContentRoute}
			Name	"Media_Global"	string
			StrictLanguageRoutingResolver	{Method = {Boolean <MapContentRoute>b__1()}}	System.Func<bool>
			Url	'((EPiServer.Web.Routing.ContentRoute)(e.RoutingSegmentContext.RouteData.Route)).Url' threw an exception of type 'System.NotImplementedException'	string {System.NotImplementedException}
			Static members	
		RouteExistingFiles	true	bool	
	RouteHandler	{EPiServer.Web.Routing.MultiplexingRouteHandler}	System.Web.Routing.IRouteHandler {EPiServer.Web.Routing.MultiplexingRouteHandler}
	Values	{System.Web.Routing.RouteValueDictionary}	System.Web.Routing.RouteValueDictionary

Hope that helps so we've got something to compare to.

#123600
Jul 09, 2015 15:03
Vote:
 

Hi,

Without debugger attached to the running process it's actually prety hard to diagnose in ones head :)

Anyway for now, just to get site up and running and serve image files, you could add following workaround:

[InitializableModule]
[ModuleDependency(typeof(InitializationModule))]
public class CustomizedRenderingInitialization : IInitializableModule
{
    public void Initialize(InitializationEngine context)
    {
        context.Locate.TemplateResolver().TemplateResolved += OnTemplateResolved;
    }

    public void Uninitialize(InitializationEngine context)
    {
        ServiceLocator.Current.GetInstance<TemplateResolver>().TemplateResolved -= OnTemplateResolved;
    }
}
public static void OnTemplateResolved(object sender, TemplateResolverEventArgs args)
{
    if (args.RenderType == typeof(ImageFile) && !PageEditing.PageIsInEditMode && args.SelectedTemplate.Name == "ImagePreviewHandler)
    {
        args.SelectedTemplate = args.SupportedTemplates.First(t => t.Name == "ContentMediaHttpHandler");
    }
}



This is nasty hack and should not be used eventually. Proper way would be to solve issue why Preview template model is selected in your project. I speculate that this may be due to Commerce existence. But that's only my humble wild guess...

#123631
Jul 10, 2015 22:24
Vote:
 

Thanks Valdis x1000 for all your advice! This hack has got it working in development for now.. I'm going to touch base with EPiServer support to see if they can assist with the deeper issue. Will report back here if I can make sense of it :)

#123634
Jul 12, 2015 5:49
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.