Small example of. NET output rewriting a compressed paging file

Source: Internet
Author: User
This article introduces a small example of the. NET output rewrite compressed paging file, and a friend in Need can refer to

I do not know if you have noticed, there are some Web site's HTML code is mixed together, without any space and newline and other extra characters. Its benefits are not to say--absolute optimization of the interface size. Perhaps you are thinking that they have done so much less readability. Indeed, we look very messy, and can only borrow third party software to rearrange the code. However, I think they develop the use of the source code can not be a no-name regiment, not long ago found a page base class, probably can explain this problem, not to say, look at the source:

Copy Code code as follows:


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.htmlControls;
using System.Text.RegularExpressions;
using System.IO;///<summary>
///pagebase page base class
///</summary>
public class Pagebase:syste M.web.ui.page
{
    protected override void Render (HtmlTextWriter writer)
     {
        stringwriter sw = new StringWriter ();
   & nbsp;    HtmlTextWriter htmlwriter = new HtmlTextWriter (SW);
        Base. Render (HTMLWriter);
        String html = sw. ToString ();
        HTML = regex.replace (HTML, "[F v]", "");
&NBSP;&NBSP;&NBsp;     HTML = regex.replace (HTML, "{2,}", "");
        HTML = regex.replace (HTML, ">[]{1}", ">");
        Writer. Write (HTML);
   }
}

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.