MVC下壓縮輸入的HTML內容

2021-09-07 08:14:26 字數 928 閱讀 6517

在mvc下如何壓縮輸出的html**,替換html**中的空白,換行符等字元?

1.首先要了解mvc是如何輸出html**到客戶端的,先了解下controller這個類,裡面有很多方法,我們需要的主要有兩個:onactionexecuting和onresultexecuted

2.新建乙個基類,繼承自:system.web.mvc.controller,**如下:

[csharp]view plain

copy

using system.io;  

using system.text;  

using system.text.regularexpressions;  

using system.web;  

using system.web.mvc;  

using system.web.ui;  

/// 

/// 在執行action的時候,就把需要的writer存起來  

/// 

/// 上下文

protected override void onactionexecuting(actionexecutingcontext filtercontext)  

/// 

/// 在執行完成後,處理得到的html,並將他輸出到前台  

/// 

/// 

protected override void onresultexecuted(resultexecutedcontext filtercontext)  

}  }  

2.需要壓縮的頁面控制器,整合這個basecontroller,就可以了,執行後的網頁源**如下圖:

MVC下壓縮輸入的HTML內容

在mvc下如何壓縮輸出的html 替換html 中的空白,換行符等字元?1.首先要了解mvc是如何輸出html 到客戶端的,先了解下controller這個類,裡面有很多方法,我們需要的主要有兩個 onactionexecuting和onresultexecuted 2.新建乙個基類,繼承自 sys...

linux下壓縮和打包的使用

檔案目錄壓縮 解壓縮 檔案壓縮 解壓縮 gzip bzip2 xz 1 gzip gz 壓縮 root node01 gzip file 1.txt root node01 file file 1.txt.gz file 1.txt.gz gzip compressed data,was 1.txt...

ubuntu下壓縮和解壓縮的命令用法

tar 解包 tar xvf filename.tar 打包 tar cvf filename.tar dirname 注 tar是打包,不是壓縮!gz 解壓1 gunzip filename.gz 解壓2 gzip d filename.gz 壓縮 gzip filename tar.gz 和 t...