This tutorial will show you how to use WebMarkupMin package to Minify HTML in ASP.NET Web Forms. The WebMarkupMin is a library that allows you to minify html content to make your web page load faster.
The WebMarkupMin.AspNet4.WebForms library is suitable for use in web applications written in ASP.NET Web Forms version 4.X
To practice, you need to install the WebMarkupMin.AspNet4.WebForms from Nuget Package Manager or you can download it directly from https://github.com/Taritsyn/WebMarkupMin
Open your code behind the page you want to compress, then change inheritance from System.Web.UI.Page to MinifiedAndCompressedHtmlPage
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebMarkupMin.AspNet4.WebForms;
namespace Fox
{
public partial class Default : MinifiedAndCompressedHtmlPage//System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
You can also minify the HTML content for the master page by changing inheritance to MinifiedAndCompressedHtmlMasterPage
Run your project, you can see your html is compressed