Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • booler 4 posts 104 karma points
    Aug 03, 2017 @ 12:33
    booler
    0

    404 on media URLs after upgrade to 7.6

    Hi,

    I have recently upgraded a 7.5 project to 7.6, and fixed the various issues which arose from model properties now returning strongly typed values.

    I'm now getting 404 errors on all the media library URLs, even though there is a valid media URL written out to the page.

    We're using Azure BLOB storage & have the provider configured. I can see the images listed in the media library (and thumbnails load correctly).

    For example in the razor script I'm using this:

    @Umbraco.GetMediaUrl(Model.MainImage)
    

    Where MainImage is an IPublishedContent. This invokes the following extension methods:

            public static string GetMediaUrl(this UmbracoHelper umbracoHelper, IPublishedContent content)
        {
            if (content == null) return null;
            return umbracoHelper.GetMediaUrl(content.Id.ToString());
        }
    
        public static string GetMediaUrl(this UmbracoHelper helper, string mediaId)
        {
            var media = !string.IsNullOrEmpty(mediaId)
                ? helper.TypedMedia(mediaId)
                : null;
    
            var mediaUrl = media != null ? media.Url : string.Empty;
    
            return mediaUrl;
        }
    

    In the page output I get this:

    <figure class="col-md-6  featured-content__image" style="background-image: url(/media/1506/some-friendly-image-path.jpg)"></figure>
    

    And the path is correct (used to work before the upgrade) - but now I get a 404.

    Any idea how to go about tracking down the issue?

    Thanks

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 03, 2017 @ 12:38
    Dennis Aaen
    1

    Hi Adam and welcome to our.

    Could you please try to navigate to /config/UmbracoSettings.config and have a look what the value of this is

    <EnablePropertyValueConverters></EnablePropertyValueConverters>
    

    It´s need to be set to false if you want to use the old media picker. Another solution would be to use this documentation

    https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/Built-in-Property-Editors/Media-Picker2

    Hope this helps,

    /Dennis

  • booler 4 posts 104 karma points
    Aug 03, 2017 @ 12:51
    booler
    0

    Thanks Dennis for the welcome & the quick response!

    I have updated the code already to work with the strongly typed values now being returned - using the extension methods above (sorry - I left those out of the original post, I have since updated it).

    I think if it was a property issue, I wouldn't get a valid path in the output markup - I'd get a compilation error. Instead, I get a valid path, which then 404s if you open it in the browser directly (and no images output to the page)

    Am I missing something obvious?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 03, 2017 @ 12:55
    Dennis Aaen
    0

    Hi There,

    Great that you got it to work. But if you are experience this again, then what I normally do is break the code down piece by piece to see when it goes wrong then you know what to focus on.

    But #H5YR for fixing this yourself.

    All the best,

    /Dennis

  • booler 4 posts 104 karma points
    Aug 03, 2017 @ 13:15
    booler
    0

    I wish it was fixed! The 404 issue remains, sadly.

    The media URL is correctly written to the markup - but if you follow the link URL you get a 404 response. So something seems to be broken in Umbraco's mapping of media URLs, though I don't know how to track down where it has gone wrong.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 03, 2017 @ 13:19
    Dennis Aaen
    0

    Hi Booler.

    Okay could you then add an issue to this issue tracker

    http://issues.umbraco.org/issues/U4

    So we can look more into this to see if it´s a problem

    Best,

    /Dennis

  • booler 4 posts 104 karma points
    Aug 04, 2017 @ 06:31
    booler
    100

    I did eventually find the solution - the upgrade process had overwritten the /media/web.config file, removing the static file handler. I reverted the change so it now looks like this:

    <configuration>
      <system.webServer>
        <handlers>
          <clear />
          <add name="StaticFileHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler"/>
          <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" 
            requireAccess="Read" />
        </handlers>
      </system.webServer>
    </configuration> 
    

    And media URLs are now working again.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 04, 2017 @ 06:55
    Dennis Aaen
    0

    Hi Booler,

    Great to hear that you managed to find the issue and get it to work agin #h5yr.

    Have a fantastic Friday, and happy coding.

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft