Need method to return Friendly URL from Media Library file on MVC site

Tim Valdez asked on April 5, 2023 17:56

Kentico 11 custom C# MVC website. Need to know how to request an image from Media Library but want the so-called Friendly name and not the GUID/GUID/etc name. When an image is selected in the ML it shows the full link and right below that it shows a "friendly" link. That's the one I want to grab in my code. How can I accomplish this?

Correct Answer

Juraj Ondrus answered on April 6, 2023 06:36

Have you checked the documentation on this topic yet? But in general, media file is a physical file. So, you just need to know the file name, file folder and media library directory and you can compose a direct link to the file system (depending on what is set in Settings too, "Media Libraries folder" setting). So, then you can compose the URL like: domain.com/mediaLibFolder/foolders/file.extension

0 votesVote for this answer Unmark Correct answer

Recent Answers


Tim Valdez answered on April 6, 2023 17:37

Thanks for that. I missed that GetUrl() in there somehow. Hoping that will work for what I need.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.