AI OnAI Off
You might want to check out UrlResolver class and more specifically the method GetUrl that accepts VirtualPathArguments. VirtualPathArguments has a property to set for specifying contextmode.Preview. That should take care of it...
I am upgrading a site from 7.1 to 7.5(7.8) and notised that one thing I use is gone in 7.5 and that is PreviewUrl, I use this one:
public static string PreviewUrl(this EPiServer.Core.PageData pageData, EPiServer.Core.PageReference specificVersion, string languageName, string latestUrl)
Member of EPiServer.UI.LinkExtensions
Resharper suggest me to use this one:
public static string PreviewUrl(this EPiServer.Core.IContent content)
Member of EPiServer.Cms.Shell.IContentExtensions
But that one does not have the possibility to send along a pageref and languagename.
Anyone knows what is a good replacement for the old one (can't find it in breaking changes document)