Today I played around a little bit more with HttpModules and implemented a more elegant solution for the problem as discussed in my previous post.
Especially the second problem - normal postback caused by ASP.NET controls - was not properly solved as it required to do the modification on every template file. Using an HttpModule avoids this overhead.
Here is the complete implementation which addresses avoids both problems discussed in the previous article:
We are moving to MSCMS and your blog is a treasure chest for us. Thanks a lot!
This was a bug. :-(
When I wrote this blog and copied the code I missed to include the "\n" chars in the script blog. The code above should work now.
Sorry for that!
Ok. It works great now! thanks
I've been digging into this issue again due to some problems with pages/postings using IE on Macs.
I'd love it if you could have a look and tell me what you think. Especially if you have ideas about multiple root channels.
I have commented your blog.
This works nicely but I added the current querystring (when available) to the 'nice url', so when available I get the Request.QueryString["NRORIGINALURL"] instead of the ChannelItem.Url.
//create the nice url
string niceurl = CmsHttpContext.Current.ChannelItem.Url;
if (x.Request.QueryString["NRORIGINALURL"] != null && x.Request.QueryString["NRORIGINALURL"].Length > 0)
niceurl = x.Request.QueryString["NRORIGINALURL"];
thanks for the suggestion. Only problem: NRORIGINALURL only works with a specific hotfix on SP1a. So it would only be a solution for users which use this hotfix....
Please could you tell me where I insert the above code? Is it in the template .aspx file? It is urgent. Thanx
I have encountered a problem with this where I seem to get random pieces of HTML appended on the end of the page after the </HTML> tag. Sometimes it happens when switching between edit mode & live mode, and sometimes just when navigating the site.
Any idea ?
you need to create a new class library project and compile the above code into a DLL. Then add this DLL to the http module section of your web.config.
Wouldn't the most elegant solution be to actually change the action value on the form to the url of the posting?
This technique is explained in the following MSDN article (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/urlrewriting.asp)
In short you create a customForm which inherits from HtmlForm and change the RenderAttributes method to correctly write the action tag. Unlike the article I set the action tag to the url of the posting.
Unfortunatly, this does not work because the Console SetPageForm method requires a HtmlForm. This method is private and I can't override it.
Do you agree that this would be the most elegant solution? Is there someother way to change the action attribute of the form tag?
not necessarily as it will require to use a different class for your forms. It is not transparent to your application.