4

I don't know if somebody has faced this strange behaviour.

I'm implementing a new site with DXA, version 1.7 and .NET with SDL Web 8.5.

I have mounted the DxaWebApp visual studio solution, with the Core views included, and make a "custom" module with my custom views. Then I have changed the default module to my own module to override the core views.

Then all works well, but my images (binaries of type "Image") are not displayed, resulting in a 404 not found of the url of the image.

The way I handle the images is the same as other views in the Core example, with:

@Html.Media(Model.image)

The url is ok, and the binary contents are in the broker database, but the problem comes when the "admin/refresh" mechanism has to check if the image is in the caché, and if it is not, then write the image file to the "BinaryData/publicationId" directory of the Site.

I have checked a default DXA site, and the differences in the log traces are:

When the image is not found by the BinaryFileManager.GetCahedFile(...) the "WriteBinaryToFile" method is not executed in my site and exits.

2017-09-15 21:24:22,721 [8] TRACE -   DefaultContentProvider.GetStaticContentItem("/Images/rewards-logo_tcm2010-2388_w1024_h1024_n.png", 2010 ('Spanish')) entry.
2017-09-15 21:24:22,727 [8] TRACE -     BinaryFileManager.GetCachedFile("/Images/rewards-logo_tcm2010-2388_w1024_h1024_n.png", 2010 ('Spanish')) : "C:\dev\Site\BinaryData\2010\Images\rewards-logo…" entry.
2017-09-15 21:24:22,732 [8] DEBUG - No value cached for key '/Images/rewards-logo_tcm2010-2388.png' in region 'BinaryPublishDate'.
2017-09-15 21:24:22,799 [8] TRACE -     BinaryFileManager.GetCachedFile() exit. Duration: 66 ms.
2017-09-15 21:24:22,803 [8] TRACE -   DefaultContentProvider.GetStaticContentItem() exit. Duration: 76 ms.

In a correct scenario, after the getCachedFile finds no image, a WriteBinaryToFile is executed and all works well

2017-09-15 21:27:27,725 [19] TRACE -   DefaultContentProvider.GetStaticContentItem("/Images/planes_tcm2010-1312_w1024_n.jpg", 2010 ('Spanish')) entry.
2017-09-15 21:27:27,728 [19] TRACE -     BinaryFileManager.GetCachedFile("/Images/planes_tcm2010-1312_w1024_n.jpg", 2010 ('Spanish')) : "C:\dev\Site\BinaryData\2010\Images\planes_tcm2010-1312_…" entry.
2017-09-15 21:27:27,731 [19] DEBUG - No value cached for key '/Images/planes_tcm2010-1312.jpg' in region 'BinaryPublishDate'.
2017-09-15 21:27:30,611 [19] TRACE -       BinaryFileManager.WriteBinaryToFile(255; 216; 255; 224; 0; 16; 74; 70; 73; 70; 0; 1; 1; 1; 0; 96; 0;…, "C:\dev\Site\BinaryData\2010\Images\planes_tcm2010-1312_…", (W=1024, H=0, NoStretch=True)) entry.
2017-09-15 21:27:30,621 [19] TRACE -         BinaryFileManager.ResizeImage(641261, (W=1024, H=0, NoStretch=True), Jpeg) entry.
2017-09-15 21:27:31,372 [19] TRACE -         BinaryFileManager.ResizeImage() exit. Duration: 746 ms.
2017-09-15 21:27:31,380 [19] TRACE -       BinaryFileManager.WriteBinaryToFile() exit. Duration: 762 ms.
2017-09-15 21:27:31,382 [19] TRACE -     BinaryFileManager.GetCachedFile() exit. Duration: 3652 ms.
2017-09-15 21:27:31,387 [19] TRACE -   DefaultContentProvider.GetStaticContentItem() exit. Duration: 3659 ms.

I don't know where this behaviour may be coming, I have changed a lot of region/entity/page view names but nothing happens, and I don't know where to view or debug this issue, or what else to try!

PROBLEM SOLVED

I finally found the problem, a shameful one; I was using the default component template instead of the DXA component template, and the images were being published without the tcmUri information. That was the reason for not finding the pictures.

But I'm still amazed by the fact that all the text fields of my components were been resolved ok in the DXA application.

Sorry guys.

  • I think it might help if you edit your question and supply a bit more detail about how you handle images in your views, since that seems to be the only change you have made (unless there is more that you changed). – Bart Koopman Sep 19 '17 at 5:38
  • From log everything seems fine. Can you check if BinaryData/<Publication> folder has "media" folder. Can you also check the mediaRoot property in BinaryData\xxx\system\config_all.json? Although, not sure but can you also check in IIS if there is sufficient rights on the application folder to write the images inside BinaryData folder. – Mukesh Kumar Sep 19 '17 at 12:05
  • In my case is an "Image" folder, as it is so that it's configured in the Images Path of the publication properties. And it exists with two images from the Example site, because when I change de default module to "Core" and publish an example page, the images get published ok to the binarydata folder – Raúl Escudero Sep 19 '17 at 17:09
2

The most likely reason for BinaryFileManager.GetCachedFile to silently exit after logging the DEBUG message (which is logged by DefaultCacheProvider.GetOrAdd) is that it could not retrieve BinaryMeta for the logged URL. See https://github.com/sdl/dxa-web-application-dotnet/blob/release/1.7/Sdl.Web.Tridion/Statics/BinaryFileManager.cs

The most obvious reason for that is that the Binary is not published, but since you say it is, there may be a more obscure problem. You could try debugging the DXA Framework to get more insight in where/how it fails exactly.

It is unlikely that this problem is related to your Views.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.