Compress and minify published ASP.NET pages
I made a small test and on a standard ASP.NET page, just only with removing whitespaces and line breaks, page size decreased by %35-40. Lower page size means higher performance. There are solutions for it but all are based on server side dynamic solutions. But there is a simplier way. For ex. just clean it when it is published and generate dynamic controls accordingly. It won't any give runtime overhead and will only give performance.
As I mentioned before also, there are of course dynamic solutions which needs extra runtime overhead, but it is a simple operation which doesn't need to be during runtime but only during publishing. Sorry to hear that it is declined. As Microsoft, you should support developers to minify all resources to make web even faster.
Now, Post-Build or After Publish events can be used on MVC projects for minification but for classic ASP.NET projects controls needed to be overridden to generate proper output or runtime solutions can be used.
Anthony Brian Wall commented
You can do it in your pages by default if you want to . Please read this post by Mads http://madskristensen.net/post/remove-whitespace-from-your-aspnet-page
Scott Galloway commented
Not sure about this, HTML minification even at best offers really minimal benefit when you also apply HTTP compression; however the potential for poor rendering in browsers is huge.
Inderjeet Wadhwa commented
Luis -- Gzip is data compression technique which needs to be uncompressed before rendering by browser so we will not get performance benefits sometime .
Inderjeet Wadhwa commented
This is read good idea. It was always uneasy to minimize each file before publishing or on run time. Doing it on run time decrease performance and minimizing files manually make it less manageable code.
No need for that. You should just gzip your page and you're done. Well... You should be doing this already...
Bertrand Le Roy commented
Almost all controls use a html text writer. It should not be too hard to pick at runtime between the regular one used today and a compressing one, based on config.
What will be more of a challenge, however, is the static strings in aspx and cshtml files. You would need a different method for those. One possibility would be to do the compression at compile-time, based on the debug/release current config. When compiling a file, the generated code could feed compressed strings to the compiler.
What is URL REDIRECTION?How can i use this concept in my .net?
my task is i have generated one url like this "http://example.com/"
I am passing one pearameter like "http://example.com/Empno=1"
I want to display Ename in Database table that corresponding "Empno"
plz Help me Give me one simple example
I am new this concepts
plz Help me send source code to my mailID:firstname.lastname@example.org
It is good, but my point is doing this on dynamic pages without any effort. So, when debugging etc. it will show full page output with indentation etc. But when it is published, it means it is ready to be deployed, clean the HTML tags and publish accordingly. So, no runtime performance decrease and we will get smaller pages.
Andrey Taritsyn commented
To HTML5-documents you can apply a more powerful minification, if the use of the approaches, which are described in Karl Seguin`s article "Minimalist Markup" - http://openmymind.net/Minimalist-Markup