aspNetMHT is a .NET component (dll) used for building and compiling MHT documents. MHT is short for MHTML. aspNetMHT can be used in any application written in .NET 1.0 and above. It is a component, or assembly, that does not have a GUI. It can only be accessed and used programmatically from .NET aspNetMHT is meant to be used by developers to build applications that support the MHT archival techniques.
So what exactly is MHT?
MHT is short for MHTML, which stands for Mime (formatted) HTML. The idea behind MHT documents is to embed all external resources, usually images, in a single document. You can think of MHTML as a HTML document with all external images, frames, etc.. embedded in the document, not just linked from the document. This allows for the document to be viewed at a later date, in it's entirety, without broken links. MHT is an internet standard, RFC #2557, and has been around since 1999. MHT was made popular when IE 5 added it to the File | Save As menu option, allowing HTML pages to be saved as type "Web Archive, single file (*.mht)".
MHT documents links to internal resources, or parts, through the use of the Content-ID or Content-Location headers. Each internal resource is considered a part, and will have it's own set of headers. The Content-ID header is an identification header that is unique to the document. The Content-Location header is a URI for the respective part. A part can be referred to by either of these headers.
The following diagram graphically shows the architecture of the MHT Document.
The parent MHT document is also happens to be a MHT object in aspNetMHT. The MHT object inherits from a MHTPart. Each parent MHT can have one or more MHTParts as children. When this object is rendered, by calling MHT.ToString(), the following equivalent text is output:
From:<Saved by aspNetMHT>
Subject: MHT Document
Content-Type: multipart/related; boundary="boundary-example"; type="text/html"
This is the body of my MHT document.
It contains 2 images <IMG SRC="fiction1/fiction2"> ... ...
The SRC values for these images actually point to references found inside of
What can I use to view MHT documents?
MHT documents can be viewed in both IE and Firefox. For IE users, version 5.0 and greater can be used. For Firefox users, a MHT plugin is required from http://maf.mozdev.org
So what does aspNetMHT do?
aspNetMHT is a .NET component (.dll) written in C#, and requires the Microsoft .NET framework to run. It is used to programmatically build MHT documents. aspNetMHT can automatically build MHT files from Urls, HTML strings, files, and ASP.NET server controls. aspNetMHT will parse the rendered HTML for external references and embed them into the single MHT document.
Can I use aspNetMHT in windows applications?
Absolutely! Since aspNetMHT was written in C#, it will run in any .NET environment or application. You can use aspNetMHT in a Windows Form application, web services, ASP.NET web pages, and any other .NET supported application.
What’s new in aspNetMHT v2
aspNetMHT v2 has been in development for almost 2 years. During that time frame we've had multiple customer requests. Many of these new features are directly related to those requests. If you ever see a MHT need, that aspNetMHT does not fulfill, we would love to hear about it. Be sure to send all feature suggestions to firstname.lastname@example.org
aspNetMHT exposes some new events for more granular control. The most useful will probably be the BeforeParseMHTPart event. This event is raised before the MHTPart is parsed, allowing the developer to control different aspects of the part.
New, easier to use Methods
Some new static methods have been exposed, allowing you to create MHT documents in a single line of code.
aspNetMHT now supports the capability to add attachments to the MHT document. This is especially useful in those instances where you need to add PDFs to your MHT documents.
New Extractor Support
aspNetMHT now provides the capability to extract a MHT document into it’s individual parts. This allows you to take an existing MHT document, and convert it back into all it’s individual pieces, and still have all the links work correctly.
Better CSS Support
There have been numerous enhancements in this area. Some where minor, but some were quite major. They include, better support for the data: format. Better handling of style tags. Better processing of @import statements. Especially nested @import statements.
More Utility Methods
aspNetMHT now has the capability to decode GZip compressed data coming over Http.
Better Local Filesystem Support
aspNetMHT can better parse local Html sources. Especially better support for UNC (\\server name\\share name) referenced content such as images.
Better Image Detection Support
aspNetMHT now has better image detection support, to better recognize images that may be mis-labeled by the server.
Better Encoding Support
aspNetMHT provides the developer with more Html encoding options, for more granular control.