Reputation: 1019
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
Reputation: 8098
please refer to this answer c# filenotfoundexception on webbrowser?
Upvotes: -1
Reputation: 17140
COM "Hack" solution here:
How do I get a C# WebBrowser control to show jpeg files (raw)?
Upvotes: 0
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
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
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