Today a newsgroup post reminded me that I did not yet publish the necessary changes for my Http Module that corrects the Ugly MCMS URLs caused by ASP.NET postbacks when ASP.NET 2.0 master pages are used.
The HttpModule I published earlier does not work in this scenario as it relies on the fact that a HtmlForm control exists in the root control collection.
This is not the case for ASP.NET master pages! Here you will find the HtmlForm control in a child collection of the MasterPage control.
And an additional problem occurs: with MasterPages I found that the ID of the HtmlForm control will not be the ID rendered in the html content. So we cannot retrieve the ID in the same way as with ASP.NET 1.1 or with ASP.NET 2.0 without master pages.
This allows us to simplify the OnInit method of the HttpModule:
public void OnInit(object sender, EventArgs eventArgs)
System.Web.UI.Page currentPage = sender as System.Web.UI.Page;
if (currentPage.Request.UserAgent.IndexOf("Mac_PowerPC") > 0)
currentPage.RegisterClientScriptBlock("__CMS_Page", // now lets register our script with the nice URL
" var __CMS_PostbackForm = theForm;\n" +
" var __CMS_CurrentUrl = \"" + CmsHttpContext.Current.ChannelItem.Url + "\";\n" +
" __CMS_PostbackForm.action = __CMS_CurrentUrl;\n" +
A small caveat exists: this version of the httpmodule is no longer compatible with ASP.NET 1.1.