Integrate all pages with the following classes to rewrite the URL and retain the PostBack address.
Using system;
Using system. Web;
Using system. Web. UI;
Using system. IO;
Using system. text;
Using system. Text. regularexpressions;
Using system. configuration;
Namespace BLL
{
/// <Summary>
/// Summary of pagebase.
/// </Summary>
Public class pagebase: Page
{
Private Static object OBJ = new object ();
//// <Summary>
/// Rewrite the default htmltextwriter method, modify the value attribute in the form tag, and set the value to the rewritten URL instead of the real URL.Www.svnhost.cn
/// </Summary>
/// <Param name = "Writer"> </param>
Protected override void render (htmltextwriter writer)
{
If (writer is system. Web. UI. html32textwriter)
{
Writer = new formfixerhtml32textwriter (writer. innerwriter );
}
Else
{
Writer = new formfixerhtmltextwriter (writer. innerwriter );
}
Base. Render (writer );
}
}
Public class formfixerhtml32textwriter: system. Web. UI. html32textwriter
{
Public formfixerhtml32textwriter (textwriter writer)
: Base (writer)
{
}
Public override void writeattribute (string name, string value, bool encode)
{
// If the current output attribute is the form-marked action attribute, replace the value with the rewritten false URL
If (string. Compare (name, "action", true) = 0)
{
Value = httpcontext. Current. Request. rawurl;
}
Base. writeattribute (name, value, encode );
}
}
Public class formfixerhtmltextwriter: system. Web. UI. htmltextwriter
{
Public formfixerhtmltextwriter (textwriter writer)
: Base (writer)
{
}
Public override void writeattribute (string name, string value, bool encode)
{
If (string. Compare (name, "action", true) = 0)
{
Value = httpcontext. Current. Request. rawurl;
}
Base. writeattribute (name, value, encode );
}
}
}
Reprinted: http://www.svnhost.cn/Article/Detail-123.shtml