Friendly URL get UnifiedFile

Member since: 2007

Hi,

Will the ConvertToInternal() method also return UnifiedFiles? If it's a page internalObject can be casted to a PageReference.

object internalObject;

if (Global.UrlRewriteProvider.ConvertToInternal(new EPiServer.UrlBuilder(url), out internalObject))
{
    UnifiedFile file = internalObject as UnifiedFile;

    if (file != null)
    {

    }
}

Or should I go with the HostingEnvironment.VirtualPathProvider.GetFile()?

#53657 Sep 18, 2011 16:35
  • Member since: 1999

    Just go with HostingEnvironment.VirtualPathProvider.GetFile, the ConvertToInternal only cares about mapping external paths to internal paths - I don't think you can get an UnifiedFile from there.

    #53667 Sep 19, 2011 13:25
  • Member since: 2007

    Why is the out parameter of type object, if it only returns page references? Would have been nice with some xml-comments on methods like these.

    #53671 Sep 19, 2011 15:04
  • Member since: 1999

    You could argue that it is too abstract but that it is how the URL rewriters are designed. The method will convert whatever you send in and return an hint (the out value) to what internal representation it used, in most cases it is a PageReference but nothing says it must be depending on the provider.

    #53672 Sep 19, 2011 15:25
  • Member since: 2007

    Is the result cached after the ConvertToInternal() is called?

    #53794 Sep 22, 2011 17:48
  • Member since: 1999

    Yes, 10 seconds by default

    #53812 Sep 23, 2011 8:46