LyphTEC
LyphTEC

Reputation: 1019

Does the WinForms WebBrowser control support mhtml content set by the DocumentText property?

Or if any body knows of an alternative control that does?

It would be handy to serve up content to the WebBrowser control that has embedded images & other resources from a database without having a dependency on these resources being hosted on a webserver or to create temporary files on the local file system.

Mhtml supports this but doesn't seem to work in a WebBrowser control when using the DocumentText property?

Upvotes: 3

Views: 2461

Answers (5)

JOE SKEET
JOE SKEET

Reputation: 8098

please refer to this answer c# filenotfoundexception on webbrowser?

Upvotes: -1

Wolf5
Wolf5

Reputation: 17140

COM "Hack" solution here:

How do I get a C# WebBrowser control to show jpeg files (raw)?

Upvotes: 0

Tom Anderson
Tom Anderson

Reputation: 10827

You could create a standard compiled resource assembly (unmanaged, not sure about managed) that contains all of your images, then link into the library like so:

<img src="res://yourdll.dll/image.jpg" />

A really good article on this and a good implementation can be found here: http://www.delphidabbler.com/articles?article=10

Personally I just used the vb6 compiler for resources only and link into them, but most non-managed compilers will do the same thing.

Upvotes: 0

sbeskur
sbeskur

Reputation: 2290

I don't think that what you are trying to achieve is possible using the DocumentText property. MHTML is a document archive format and although it is stored as text with binary data such as images etc. encoded to base64 strings, there does not seem to be any intelligence built into the DocumentText property of the webbrowser control to read this file format. Looking into this property with Reflector you will see that a different mechanism is used to handle this as opposed to the Url property which invokes the "guts" of the webbrowser control via the underlying COM object.

It also doesn't appear that you can accomplish this by writing to the DocumentStream property either.

Upvotes: 2

sbeskur
sbeskur

Reputation: 2290

Seems to be working for me.

example:

this.webBrowser1.Url = new System.Uri(@"C:\TempFiles\MyTest.mht");

what in particular is not working correctly?

Upvotes: 1

Related Questions