We also discuss the issue of Form Action attributes when UpdatePanel and UrlRewrite work together.

Source: Internet
Author: User
First of all, I would like to thank Lao Zhao for writing an article, http://www.cnblogs.com/JeffreyZhao/archive/2006/12/27/604373.aspx#post

In fact, this problem is not a MS Ajax error at all, it is completely the reason why we did not use URLRewrite.

Lao Zhao's solution is to rewrite a Form class and clear the original Form Action.

I don't know if I can work normally, but I think it is very dangerous to use the default attribute to clear it .~~~

Rewriting the Form class makes reference a little troublesome. I think it is more convenient to rewrite a Page. My practice in www.365rss.cn is as follows:

Using System;
Using System. IO;
Using System. Web;
Using System. Web. UI;
Namespace okpower. Utility
{
/** // <Summary>
/// URLRewrite Page Base Class
/// By Kai. Ma http://kaima.cnblogs.com
/// </Summary>
Public class URLRewritePage: Page
{
Public URLRewritePage ()
{
}

Protected override void Render (HtmlTextWriter writer)
{
Writer = new FormFixerHtmlTextWriter (writer. InnerWriter );
Base. Render (writer );
}
}

Internal class FormFixerHtmlTextWriter: System. Web. UI. HtmlTextWriter
{
Private string _ url;
Internal FormFixerHtmlTextWriter (TextWriter writer)
: Base (writer)
{
_ Url = HttpContext. Current. Request. RawUrl;
}

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 (_ url! = Null & string. Compare (name, "action", true) = 0)
{
Value = _ url;
}

Base. WriteAttribute (name, value, encode );
}
}

}

You can inherit this URLRewritePage in the future, or even set it in web. config, once and for all.
Welcome

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.