views:

266

answers:

3

For a client server application, I'd like to display content with a web browser control with images without writing temporary files to the disk.

I've tried using mht files via documentstream and documenttext, but the web browser control isn't smart enough to recognize mht files.

I would use data URI images, however most computers this will be installed on use IE6 or 7.

Are there any other options for this?

A: 

Load the Web site, but add a no-cache header. Something like as follows:

WebBrowser web = new WebBrowser();
web.Navigate("http://yourURL.com", string.Empty, null, "Pragma: no-cache");
Kyle Rozendo
A: 

I'm not sure if it would help at all, but maybe you could try using a different browser control such as WebKit .NET?

That way you could be certain about its features (mht, data URI, etc.)

I know how much of a pain the Microsoft web browser component can be.

NickAldwin
It appears the dependencies for Webkit.NET are 11MB, and it's not a 1.0 or better release, so I don't think I'd be able to use it.After additional googling I'm not sure there is a proper solution for this. I think I may just have to forego images and stick with DXImageTransforms for layout. Some icons would have been nice... but won't fit in the framework as it is.
Revision17
Hm, that's unfortunate. I know my company's webbrowser-served-pages use images served from our website (thus no files on disk). Maybe you could do something like that?
NickAldwin
And how would it be possible to give webkit control image/css/js resources without temp files?
grega g
I was simply suggesting maybe it supports mht or data URIs.
NickAldwin
A: 

You can register your own protocol for images

If you want to go through the MHTML route, you need to call the document's IPersistStreamInit/IPersistMoniker by yourself. If I remember correctly the WinForm WebBrowser control assumes the input stream to be UTF-8, and does not provide a IMoniker implementation to let you specify the base url of the document.

Note there are some limitations on IE's MHTML support, such as not all protocols are supported, site limits on MHTML attachments, lack of MHTML support on mobile phones and early versions of Windows for PC without Outlooks Express or Word, etc.

Sheng Jiang 蒋晟