This happens because your context site is "shell" .
You need to switch to website site using :
using (new SiteContextSwitcher(Factory.GetSite("website")))
{
url = MediaManager.GetMediaUrl(mediaItem);
}
This happens because your context site is "shell" .
You need to switch to website site using :
using (new SiteContextSwitcher(Factory.GetSite("website")))
{
url = MediaManager.GetMediaUrl(mediaItem);
}