Although I generally belong to only read not to write people, but from a post even more than a year apart, have to sigh time is really fast scary ah ...
A recent venture to launch a Web 2.0 project, previously on Ajax, URL rewriting technology and the so-called Xhtml+css+div only stay in the theoretical phase, now has the opportunity to put into practice, As a result, when you play Urlrewrite, you will encounter the inevitable ASP.net httpform automatically assign the real page address to the action attribute.
Online Google a bit, the solution is three kinds, add client java script, Overload httpform or page class
Lao Zhao This post explains how to add client script and overload the Httpform class: Http://www.cnblogs.com/JeffreyZhao/archive/2006/12/27/604373.html
And Marco (I hate to use seniority to call it the comrade of net name ...) Next time I change my name to the Godfather, hey. This article illustrates the method of overloading page: http://www.cnblogs.com/kaima/archive/2006/12/27/604758.html
Urlrewrite itself has the role of hiding server processing details, this part to the client to do the feeling is very awkward, so the Java script scheme was quickly rejected by me.
The overloaded Httpform class was also rejected by me, and the Renderatttributes method of Httpform also contained code to handle client onsubmit events, and a considerable number of Web controls relied on this part of the reflector to view the code. When removed, the frame structure is destroyed. MSDN is a way to teach this, and indeed MSDN is a thing to be skeptical about.
The method introduced by Marco is reasonable, but I think that overloading the page class is also the behavior that should be avoided in general, one is to decide which page to use the new leaf class which pages do not bother, if in order to save trouble, Then set the PageBaseType property in the web.config, but the whole site's page will have to go through this class also does not conform to the details of the entrepreneurial site requirements.
Is there a better way to do it? Also really has, is I today in the research asp.net CSS friendly adapters the time awakes.
This solution is based on the Marco of the above scheme, but only if you must have. NET 2.0 support.
The. NET 2.0 framework adds several special directories to ASP.net, one of the most easily overlooked app_browsers directories, which are used to store browser definition files, which can be referenced in msdn:http://msdn2.microsoft.com/ zh-cn/library/ms228122 (vs.80). aspx
Create a app_browsers directory in the root directory of the Web site, and create a new file name in the Rewriteform.browser, which reads as follows:
<browsers>
<browser refID="Default">
<controlAdapters>
<adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
adapterType="Kuang.HtmlFormAdapter" />
</controlAdapters>
</browser>
</browsers>
Where the refid= "Default" attribute of the browser section is the Default.browser file that represents the existing extension system (located at%windir%\microsoft.net\framework\v2.0.50727\config\ Browsers), Default.browser is the root of all browser definitions, please refer to the MSDN instructions for details.
Adapter means adapters, which represent objects that coordinate between two objects in the. NET realm, such as the well-known SqlDataAdapter class in Ado.net is the adapter that is coordinated between the SqlCommand and the dataset.
ASP.net 2.0 brings the concept of ControlAdapter, The meaning is the adapter between the System.Web.UI.Control object and the ASP.net, as well as the pageadapter, which is used to process the System.Web.UI.Page object.
ControlAdapter does not have any special functionality, except that it provides the ability to overload a Web control render method without inheriting the control, and can only target specific controls, such as the HtmlForm class here, compared to the overloaded page class method. In the Marco method, if there are other controls that also use the action attribute, they are rewritten incorrectly. In Rewriteform.browser file, through <adapter controltype= "System.Web.UI.HtmlControls.HtmlForm" adaptertype= " Kuang.htmlformadapter "/> This line, I specified the HtmlForm class to overload, and provided the type kuang.htmlformadapter of my custom ControlAdapter class.