Did you try with
UrlResolver.Current.Route(new UrlBuilder(urlAsString), ContextMode.Edit); ? If you pass the ContextMode parameter, it will use Default.
Yes. Tried with both.
If it is a custom IContent implemention you need to implement EPiServer.Web.IRoutable.
Also UrlResolver.GetUrl will return null if the content does not have a page template (meaning the link will end up in a 404 anyway), you can disable template validation for UrlResolver by using overload that takes a VirtualPathArguments and in there set ValidateTemplate=false
Maybe I was a bit unclear. I don't want to generate the URL, I want to resolve the IContent from an URL. In this case it's a MediaData, hence no template, but that should only matter if I want to generate the URL I guess. And there is no overload that takes VirtualPathArguments.
As a side note: MediaData actually has a template, in that case the template is a HttpHandler (ContentMediaHttpHandler).
If you want to resolve a content from a url you would use UrlResolver.Route(UrlBuilder) that should handle media.
Alright. Then its even more strange that the above code doesn't work. I think I have to set up some more isolated tests with the above URL.
Now it seems to work when adding ContextMode.Edit as well. Not sure why it didn't work the first time.
I have an url to a document in the internal format (/episerver/CMS/Content/globalassets/test/requirements.xlsx,,824?epieditmode=False), how can I get the corresponding IContent from that url?
I've tried with UrlResolver without any luck :(