从ASP.Net MVC应用程序压缩HTML输出 [英] Minify HTML output from an ASP.Net MVC Application

查看:462
本文介绍了从ASP.Net MVC应用程序压缩HTML输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是以下问题的重复,但唯一的答案是一个死链接:结果
<一href=\"http://stackoverflow.com/questions/255008/minify-html-output-of-asp-net-application\">http://stackoverflow.com/questions/255008/minify-html-output-of-asp-net-application

This is likely a duplicate of the below question but the only answer is a dead link:
http://stackoverflow.com/questions/255008/minify-html-output-of-asp-net-application

当与ASP.Net工作的更恼人的方面我之一是,Visual Studio中把空格代替标签为白色间距这增加了最终的HTML的尺寸的事实。我原本以为的简单改变Visual Studio的设置,使用标签来代替,但那么别人在我的球队仍然将结束反正用空格覆盖。

When working with ASP.Net one of the more annoying aspects to me is the fact that Visual Studio puts spaces instead of tabs for white spacing which increases the size of the final HTML. I originally thought of simply changing Visual Studio settings to use tabs instead but then others on my team will still end up overlaying with spaces anyway.

我的问题是双重的:首先是有没有办法在每个项目的设置更改,如果使用空格或制表符(并且它甚至值得的,如果这样);第二,有没有办法简单地缩小所有的意见时产生的?

My question is two fold: first is there a way to on a per project setting to change if spaces or tabs are used (and is it even worthwhile if so) and second, is there a way to simply minify all of the views when generated?

推荐答案

<一个href=\"http://weblogs.asp.net/rashid/archive/2008/03/28/asp-net-mvc-action-filter-caching-and-com$p$pssion.aspx\"相对=nofollow>启用GZIP 会比与缩小你的HTML,反正多的效果。

Enabling GZIP will have much more effect than minifying your HTML, anyway.

在运行时做微小可能会损害您的服务器(假设你不使用缓存)。这可能是在部署期间minfiy您Asp.Net的标记是个好主意。这样一来,你还有你的code库中的code的非缩小的版本,并在服务器上一个缩小的版本。想在那里你调用一个HTML minifier(例如,该工具由院长休谟看起来部署过程所有有为)的.aspx 文件。

Doing minification at runtime could hurt your servers (assuming you don't use caching). It may be a good idea to minfiy your Asp.Net markup during deployment. This way, you still have a non-minified version of code in your code repository, and a minified version on the server. Think of a deployment process where you invoke an HTML minifier (for instance, this tool by Dean Hume looks promising) on all .aspx files .

这篇关于从ASP.Net MVC应用程序压缩HTML输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆