HtmlFormEx: A URL rewriter friendly form

Posted at Fri, 06 Jan 2006 05:03:34 GMT by Wilco Bauwer

ASP.NET's built-in form control renders an action attribute. Its value is a path that refers to the current page. This is usually the path after a URL rewriter has rewritten a friendly URL to the actual URL. While it looks like a rewriter works properly, you will learn that postbacks don't actually work as expected: they postback to the actual URL instead of the friendly URL.

To work around this, I have implemented a derivation of the built-in HtmlControl in ASP.NET 2.0. You can grab it from the toolbox. The implementation is trivial: I implemented a ProxyHtmlWriter that is used temporarily in the PreRender phase of the HtmlForm (in which the attributes are rendered). This proxy HTML writer takes care of omitting the RawUrl instead, which is the URL that the user should see in their browser.

Wouldn't the new RewritePath overload you point to in my post provide a solution for this problem?
http://weblogs.asp.net/fmarguerie/archive/2006/01/11/435022.aspx
The problem with the ASP.NET HtmlForm is that it uses the translated path, while you want it to be the path that the user requested (ie. the friendly url). This doesn't have anything to do with rebasing client paths, which is about how relative urls are resolved.
Oh ok. I had hoped this had been fixed in some way in ASP.NET 2.
Your message will be encoded/formatted when it is displayed. If you want to post code, please put the code inside [code=X][/code] tags, where X is the language of your code (C#, ASPX, SQL, etc).
Name:
Email:
(will be encoded using JavaScript to keep it functional and prevent it from being picked up by spammers)
Url:
 
Message:
3 + 3 =