I have already posted two articles about how to solve the "ugly" URL problem. In the last article I discussed a solution based on a custom http module which does all the necessary checks and adjustments.
But one issue is still unsolved: Internet Explorer on Mac has an ugly bug then whenever the "action" property of a form tag is modified using Javascript a click to all items - even a label - will cause a postback to the server.
To solve this problem Microsoft has posted a fix for MCMS which will avoid this. But my code in the solution referenced above does exactly the same. So using this code in an environment will produce the error again. To avoid this problem it is necessary that the original action property of the template is modified on the server side rather than on the client side.
I looked through lots of documentation but did not find a solution for this dilemma which works in all situations - even if it is necessary to change the action property to point to a location in a different web application.
So finally I decided to implement an http stream filter to solve this problem. The stream filter needs to intercept the http response stream just before it is send to the client and has to modify the action property of the form tag. As this is not a very elegant solution I implemented the filter in a way hat it will only be active if the client requesting is a Mac client.
Below is the code for the relevant stream filter most of the code is only implementing mandatory methods and properties. The real work is done in the Write method:
To integrate this filter into the response stream I integrated the following code in the OnPreRequestHandlerExecute handler:
To also allow usage of this filter with forms authentication and still handle expired cookies correct you will have to encapsulate the content of the OnPreRequestHandlerExecute routine in a try-catch block as in this situation accessing the CmsHttpContext.Current will give you an access denied exception.
public void OnPreRequestHandlerExecute(object sender, EventArgs e) { HttpContext ctx = ((HttpApplication)sender).Context; IHttpHandler handler = ctx.Handler;
try { ... } catch { // this will happen if the request is in the middle of an expired forms authentication login // we just ignore this. }}
Finally I modified the OnInit event to ensure that the __CMS_Page script block is only injected if the browser is not an Mac IE client.
By registering a blank script block for the __CMS_Page script block it is now ensure that the postback issue is also resolved without the hotfix mentioned above.
To implement this solution either modify the code listed here or wait a couple of days till the complete code shows up on GotDotNet. It will take a few days to get the update approved. Just check it out next week.