AI OnAI Off
protected void Application_Start(object sender, EventArgs e)
{
Global.UrlRewriteProvider.ConvertingToInternal += new EventHandler(UrlRewriteProvider_ConvertingToInternal);
}
void UrlRewriteProvider_ConvertingToInternal(object sender, UrlRewriteEventArgs e)
{
e.Cancel = e.Url.Path.EndsWith(".aspx");
}
Regards,
Tibi
PageData.LinkURL
returs a classic old school URL. Which means that if you take no special measures to convert it and don't render it as ahref="LINK_HERE"
you end up dealing with those URL:s, and, you want this old way of accessing a page to still work. However, if you have Friendly Urls turned on (default) and happen to access a page with /templates/MyPage.aspx?id=3&epslanguage=SV you get the StartPage (fallback mechanism). Ok, so they (EPiServer) have removed the possibility of loadingCurrentPage
through the id querystring param? Answer: no. The default mechanism inget_CurrentPageLink
gets the id querystring param and loads the corresponding page through GetPage. Now the surprise. The id querystring param isn't there anymore. The very friendly rewrite engine rewrites this url to the much more user friendly /templates/MyPage.aspx?epslanguage=SV Ooops...where did my id querystring param go? Why did you remove it? And then, if you remove it, why the dependancy inget_CurrentPageLink
. Maybe only intended for scenarios where you have friendly urls turned off? Ok, next experiment, we create another .aspx file on the root: Simple.aspx. No inheritance from EPiServer, just a VERY plain WebForm. Its sole content:<%=request.querystring%> %=request.querystring%>
We access it with /Simple.aspx?a=b&id=3 Resulting printout: a=b Ooops? So EPiServer takes the liberty to remove the id querystring param for all pages, not justPageBase
pages. I can actually think of scenarios where the id attribute is used in a non EPiServer sense...sad to break that compatibility. My solution to this problem: MyFriendlyUrlRewriteProvider.csnamespace MyNamespace { class MyFriendlyUrlRewriteProvider: EPiServer.Web.FriendlyUrlRewriteProvider { public override bool ConvertToInternal(EPiServer.UrlBuilder url, out object internalObject) { internalObject = null; if (url.Path.EndsWith(".aspx")) return false; return base.ConvertToInternal(url, out internalObject); } } }
web.config (in episerver/urlRewrite/providers)