asp.net output Rewrite compressed paging file instance code

Source: Internet
Author: User
Tags config

  This article mainly introduces the asp.net output rewrite compressed page file instance code, the need for friends can refer to the following

Examples     code are 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:System.Web.UI.Page {    prot ected override void Render (HtmlTextWriter writer)     {        StringWriter SW = new String Writer ();         HtmlTextWriter htmlwriter = new HtmlTextWriter (SW);         base. Render (HTMLWriter);         string html = sw. ToString ();         HTML = regex.replace (HTML, "[F v]", "");         HTML = regex.replace (HTML, "{2,}", "");         HTML = regex.replace (HTML, ">[]{1}", ">");       &NBSP Writer. Write (HTML);    }     add several. NET compression modules   One, webresourcecompression compression module     This compression module is designed for real-time compression of all *.axd resources referenced by asp.net2.0 pages, and the general ASPX page uses an AJAX framework such as Anthem.net or asp.net validation control will produce Axd file references, this file is actually a JS script, enabling this compression module, all the Axd resources will be gzip compressed and then transmitted to the client, this module is particularly suitable for the ASPX page application of the AJAX framework or a large volume of axd resource files to refer to the project !   Use: Put the WebResourceCompression.dll in the bin directory of the Web site project after decompression, and add the following statement to the Web.config <httpModules> configuration section:  code as follows:     Code as follows: <add name= "webresourcecompression" type= "Webresourcecompression.webresourcecompressionmodule "/>   Advantages: Use simple   disadvantage: only support asp.net2.0 or above version, can not compress other resources except Axd!"   II, pagecompression compression module       Unlike the previous modules, this module is designed to compress ASPX pages, after enabling this compression module, the ASPX page will be compressed in real time, General 100K pages can be compressed to about 25K, this module is suitable for the page only need to compress the project!   Use: Put the Compression.PageCompressionModule.dll in the bin directory of the Web site project after decompression, and add the following statement to the Web.config <httpModules> configuration section:   Code as follows: The   code is as follows: <add name= "Pagecompressionmodule" type= "Compression.pagecompressionmodule, Compression.pagecompressionmodule "/>   ExcellentPoint: Use simple   disadvantage: support only asp.net2.0 or above, cannot compress other resources except ASPX page, and when compression is enabled, the Axd resource of the page reference will be invalid (BUG)!   HttpCompress6.0 Compression module       This is a support asp.net1.0/1.1/2.0 (2.0 version does not support gzip compression, only support deflate compression), You can compress the resources of all types (mimetypes) of the ASPX page request, including pictures, JS scripts, Axd, aspx pages, CSS files, and so on, and you can customize the web.config in detail to compress that type of resource and not compress that type of resource, You can also define a powerful customization that compresses the specified page or does not compress the specified page, plus the compression ratio setting (High|normal|low), and so on. However, the most serious problem with this control is that enabling compression under asp.net2.0 causes the Axd file to become invalid, so that AJAX functionality is invalidated if the page applies an AJAX framework.   use: Slightly (similar to the Compressionmodule compression modules recommended below)   Advantages: Open source code, powerful customization, support asp.net1.0/1.1/2.0 version, can compress a variety of resources!  Disadvantage: The use of complex, asp.net2.0 to enable compression will cause Axd file invalid!  
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.