Lets say I have the ContentReference for a file, a MediaData.
Ok, so how can I get the link to this file?
Didn't find much info in SDK or 7.5 pages on World...
Same goes with the AssetsFolder, how get the link?
I have played around with:
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var folder = contentRepository.GetDefault<ContentAssetFolder>(pub.AssetFolder);
but the folder object doesn't contain much
Any advice would be appreciated!
You could use UrlResolver (resides in EPiServer.Web namespace), you can either get an instance from IOC container or use static property Current.
UrlResolver have several overloaded methods GetUrl that returns links. The most basic one takes a single ContentReference and returns the url in the same format as the current context is executing (so if the code executes on site the url will be public while if the code is executign e.g. in onpageedit mode the url will be in edit format.)
looked forever for that