1
在我MVC3項目中的所有頁面具有以下HTML作爲輸出如何在MVC3中過濾和壓縮輸出HTML?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My app</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="">
<link href="/Content/bootstrap.min.css" rel="stylesheet">
<link href="/Content/bootstrap-responsive.min.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="shortcut icon" href="/Content/icons/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/Content/icons/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/Content/icons/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/Content/icons/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="/Content/icons/apple-touch-icon-57-precomposed.png">
</head>
<body>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div class="well">
<h2>Test</h2>
</div>
</div>
</div>
<hr>
<footer>
<p>©</p>
</footer>
</div>
<script src="/Scripts/jquery-1.8.2.min.js"></script>
<script src="/Scripts/bootstrap.min.js"></script>
</body>
</html>
不過,我怎樣才能使一個過濾器,修剪行和刪除空行,以獲得類似於下面的示例輸出...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My app</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="">
<link href="/Content/bootstrap.min.css" rel="stylesheet">
<link href="/Content/bootstrap-responsive.min.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="shortcut icon" href="/Content/icons/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/Content/icons/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/Content/icons/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/Content/icons/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="/Content/icons/apple-touch-icon-57-precomposed.png">
</head>
<body>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div class="well">
<h2>Test</h2>
</div>
</div>
</div>
<hr>
<footer>
<p>©</p>
</footer>
</div>
<script src="/Scripts/jquery-1.8.2.min.js"></script>
<script src="/Scripts/bootstrap.min.js"></script>
</body>
</html>
檢查這個問題,其他有用:http://stackoverflow.com/questions/255008/minify-html-output-of-asp-net -應用。 – fegemo