asp.net the content of the page before the page is generated and the content is printed

Source: Internet
Author: User
Tags net response write
Asp.net| page

Previously said to use HttpModule to change cookies before response, today encountered ASP.net to do their own ideas, I have to work hard to convert the Chinese characters ꪻ such a manifestation, and turn into Chinese characters, not to mention the ASP.net Web control, is the HTML control ranat= The server will be forcibly converted into Chinese character output.
If the page content line with response write out, that is too tired, and error prone. So the best way to do this is to do a conversion once the asp.net is done, so that asp.net takes you out of the way.
asp.net all of the build actions are done in the Render method, then we operate on the Render method:


protected override void Render (HtmlTextWriter writer)
        {
           
             StringWriter sw = new StringWriter ();
            HtmlTextWriter HTMLW = new HtmlTextWriter (SW );
           //Take out the page-building content
             base. Render (HTMLW);
            HTMLW. Flush ();
            HTMLW. Close ();
            string pagecontent = sw. ToString ();
           //modify content
           &nbSp PageContent = Killthebugandshit (pagecontent);

Response.Write (PageContent);

Base. Render (writer);
}
Using this method, you can also take the content generated by the page to generate a static page to use.

(as if I had written this post last year ...) No, I don't remember.







Related Article

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.