A few questions about the FriendlyHtmlRewriteToExternal
Assume I have PageType A which uses A.aspx as template. In my PageTree I have a page (MyPage) of type A with id 10. From another page, I want to make a link to MyPage, using B.aspx as template. The 4.61 way to do this would be to make a link to /templates/B.aspx?id=10. In CMS the FriendlyHtmlRewriteToExternal exchanges my link with the friendly url to MyPage, using A.aspx as template. How to write the links if I want to use different templates to the same PageType? I guess I could use my own querystring-id-parameter and override CurrentPage. Any better way?
Also, a Server Error (xx is not a valid PageID) appears if using an ID which not exists in the PageTree. Why a crash? Couldn't EPiServer just leave the link as is?
results in a Server Error (Invalid URI: The hostname could not be parsed). Of course the best thing is to avoid empty mailto-links, but again, a crash is even worse.
Stack trace from above Error (empty mailto):
[UriFormatException: Invalid URI: The hostname could not be parsed.]
System.Uri.CreateHostStringHelper(String str, UInt16 idx, UInt16 end, Flags& flags, String& scopeId) +164
System.Uri.CreateHostString() +226
System.Uri.EnsureHostString(Boolean allowDnsOptimization) +63
System.Uri.GetComponentsHelper(UriComponents uriComponents, UriFormat uriFormat) +67
System.Uri.GetComponents(UriComponents components, UriFormat format) +73
System.Uri.get_Host() +22
System.UriBuilder.Init(Uri uri) +50
System.UriBuilder..ctor(Uri uri) +154
EPiServer.UrlBuilder.Init(Uri url) +58
EPiServer.UrlBuilder.get_ThisBuilder() +37
EPiServer.UrlBuilder.get_QueryCollection() +17
EPiServer.Web.PermanentLinkUtility.GetPageReference(UrlBuilder mappedUrl) +99
EPiServer.Web.FriendlyHtmlRewriteToExternal.HtmlRewriteUrl(UrlBuilder internalUrl, UrlBuilder externalUrl, UrlBuilder url, Encoding encoding, Object& internalObject) +141
EPiServer.Web.FriendlyHtmlRewriteToExternal.rewritePipe_HtmlRewriteUrl(Object sender, HtmlRewriteEventArgs e) +299
EPiServer.Web.RewritePipe.OnHtmlRewriteUrl(HtmlRewriteEventArgs e) +20
EPiServer.Web.HtmlRewritePipe.WriteElement(MyHtmlRewriteEventArgs e, SgmlReader reader, TextWriter writer) +426
EPiServer.Web.HtmlRewritePipe.RewriteToEnd(TextReader reader, TextWriter writer) +1532
EPiServer.Web.HtmlRewriteStream.Close() +162
System.Web.HttpWriter.Filter(Boolean finalFiltering) +310
System.Web.HttpResponse.FilterOutput() +85
System.Web.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +46
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
results in a Server Error (Invalid URI: The hostname could not be parsed). Of course the best thing is to avoid empty mailto-links, but again, a crash is even worse. Stack trace from above Error (empty mailto): [UriFormatException: Invalid URI: The hostname could not be parsed.] System.Uri.CreateHostStringHelper(String str, UInt16 idx, UInt16 end, Flags& flags, String& scopeId) +164 System.Uri.CreateHostString() +226 System.Uri.EnsureHostString(Boolean allowDnsOptimization) +63 System.Uri.GetComponentsHelper(UriComponents uriComponents, UriFormat uriFormat) +67 System.Uri.GetComponents(UriComponents components, UriFormat format) +73 System.Uri.get_Host() +22 System.UriBuilder.Init(Uri uri) +50 System.UriBuilder..ctor(Uri uri) +154 EPiServer.UrlBuilder.Init(Uri url) +58 EPiServer.UrlBuilder.get_ThisBuilder() +37 EPiServer.UrlBuilder.get_QueryCollection() +17 EPiServer.Web.PermanentLinkUtility.GetPageReference(UrlBuilder mappedUrl) +99 EPiServer.Web.FriendlyHtmlRewriteToExternal.HtmlRewriteUrl(UrlBuilder internalUrl, UrlBuilder externalUrl, UrlBuilder url, Encoding encoding, Object& internalObject) +141 EPiServer.Web.FriendlyHtmlRewriteToExternal.rewritePipe_HtmlRewriteUrl(Object sender, HtmlRewriteEventArgs e) +299 EPiServer.Web.RewritePipe.OnHtmlRewriteUrl(HtmlRewriteEventArgs e) +20 EPiServer.Web.HtmlRewritePipe.WriteElement(MyHtmlRewriteEventArgs e, SgmlReader reader, TextWriter writer) +426 EPiServer.Web.HtmlRewritePipe.RewriteToEnd(TextReader reader, TextWriter writer) +1532 EPiServer.Web.HtmlRewriteStream.Close() +162 System.Web.HttpWriter.Filter(Boolean finalFiltering) +310 System.Web.HttpResponse.FilterOutput() +85 System.Web.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +46 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64