Emitting mhtml to browser with ASP.NET

Discussion in 'ASP .Net Building Controls' started by Jason von Bartheld, May 26, 2004.

  1. 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--
     
    Jason von Bartheld, May 26, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stream mhtml to browser

    , Dec 15, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    507
  2. =?Utf-8?B?TUVSNzg=?=

    MHTML Streaming

    =?Utf-8?B?TUVSNzg=?=, Feb 24, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,940
    jgoodale
    Feb 6, 2006
  3. Peter Rilling
    Replies:
    0
    Views:
    405
    Peter Rilling
    Feb 9, 2006
  4. k mcnamee
    Replies:
    0
    Views:
    205
    k mcnamee
    Oct 16, 2003
Loading...

Share This Page