Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Emitting mhtml to browser with ASP.NET

Reply
Thread Tools

Emitting mhtml to browser with ASP.NET

 
 
Jason von Bartheld
Guest
Posts: n/a
 
      05-26-2004
Hi,
I am building a control in ASP.NET that will cache mhtml pages in a database
and then return those
pages to the browser based on keyword searches. Right now I am doing a test
where I fetch the html page using the
chilkat mht component, convert it to mht format and spit it back out to the
browser. Everything works fine except the encoding setting seem to be
incorrect in this code

protected override void Render(HtmlTextWriter output) {
Chilkat.Mht mht = new Chilkat.Mht();
Response.ContentType = "text/html";
if (mht.UnlockComponent("226401D934A3140")) {
output.Write(mht.GetMHT("http://l36.net/test.html"));
}
}

The results of this, taken from the webbrowser after "view source" show the
valid mhtml that I pasted below.
If you were to view source on the output page, paste the content into
notepad and save it as test.mht with ANSI encoding, things work great. This
leads me to believe that the problem is actually in ASP.NET not
telling the browser to expect mhtml.
Does anybody know what the proper settings for the Response object should
be? I have tried the following
Response.ContentType = "message/rfc822"; //Page cannot be displayed message

Response.AddHeader("Content-Disposition", "attachment;
filename=Report.mht"); --Pops up 'saveas' box that saves the file properly.

I am hoping it is just a problem with these settings.
Thanks,
-Jason

Here is sample output:

content-type: multipart/related; charset="us-ascii"; type="text/html";
boundary="----=_NextPart_516_2b2d_2ec24bf1.75cbb67c_.REL"
MIME-Version: 1.0
Subject: http://www.l36.net
Date: Mon, 24 May 2004 23:35:42 -0400

This is a multi-part message in MIME format.

------=_NextPart_516_2b2d_2ec24bf1.75cbb67c_.REL
content-type: text/html; charset="utf-8"
content-transfer-encoding: quoted-printable
Content-Location: http://www.l36.net/

<h1>SchoolBooks.org</h1>
<h3>We are at a new host and will be back up soon</h3>
------=_NextPart_516_2b2d_2ec24bf1.75cbb67c_.REL--



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Internet Explorer MHTML URI Buffer Overflow Vulnerability Imhotep Computer Security 0 06-03-2006 02:52 AM
Announcement: Cool MHTML library available for review (pre-alpha). Peter Rilling ASP .Net 0 02-09-2006 03:54 AM
MHTML Streaming =?Utf-8?B?TUVSNzg=?= ASP .Net 2 02-06-2006 07:13 PM
'mhtml' files Earl Costello Computer Support 5 03-10-2005 07:05 PM
Stream mhtml to browser mparker@costar.com ASP .Net 0 12-15-2003 06:09 PM



Advertisments