Copied to clipboard

Flag this post as spam?

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


  • Ilya 2 posts 72 karma points
    Jan 24, 2019 @ 16:33
    Ilya
    0

    Hello,

    I have a following problem. My live website is exactly the same as my staging. But when I am trying to download a file from the live site, the file is not found. Here is C# code:

     public ActionResult Index(string name)
        {
            var doc = Umbraco.TypedMediaAtRoot().DescendantsOrSelf<File>().FirstOrDefault(file => file.ShortName == name);
    
            if (doc == null)
            {
                var productsAndInsurers =
                    Umbraco.TypedContentAtRoot().DescendantsOrSelf<CustomerInsurers>().FirstOrDefault();
                return RedirectToUmbracoPage(productsAndInsurers);
            }
    
            return Redirect(doc.Url);
        }
    

    On staging the correct file is returned, on live - doc is null and the site is redirected to the home page. The file is definitely there, I can open it from Umbraco back office. Does anyone know what the problem might be?

    Thank you

  • Nik 1591 posts 7148 karma points MVP 6x c-trib
    Jan 24, 2019 @ 17:00
    Nik
    0

    Hi ILya,

    Can you confirm that the file exists on the disk for the live site?

    So browsing the file system, go to the media folder, find the correct folder in there (look at the URL for the media file on your staging site, it should be in the format /media/1234/filename.extension, to get the folder number) and confirm the file exists there as well?

    It's possible that the media folders differ between your environments so it's worth a check :-)

    Nik

  • Ilya 2 posts 72 karma points
    Jan 25, 2019 @ 10:15
    Ilya
    0

    Hello Nik,

    Thank you for your reply.

    The file is definitely there. But something weird happened. I republish the whole site yesterday. Tried to download the file, it did not work and then I posted the question. This morning I came to work tried the same URL and it worked! I am a bit confused now.

    Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft