MediaService.GetMediaByPath always returns null on HttpApplication events

Hi, I’m currently in need to get a media item by its url. The funcion provided in the MediaService always returns null no matter what, while if I get an item by its ID it’s perfectly fine.

My code is running on an HttpApplication event, more precisely the PreSendRequestHeaders

Sample code:

                IMedia media = ApplicationContext.Current.Services.MediaService.GetMediaByPath(app.Request.Url.AbsolutePath);

This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/75866-mediaservicegetmediabypath-always-returns-null-on-httpapplication-events