By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,117 Members | 2,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,117 IT Pros & Developers. It's quick & easy.

Displaying HTML from memory

P: n/a
Hi

I have many short HTML files stored in a binary stream storage to display
descriptions for various items in application. HTML would be display inside
application using some .NET control or COM control (like Microsoft
WebBrowser). For each description there is one HTML file and along
description text, it contains links to related information. Clicking related
information would for example open new form in application and display some
list of items from DB.

When I load HTML data from stream storage, it is stored in memory inside
memory stream. I could display HTML data by first saving memory stream
contents in a temporary file and then instruct browser control to load from
that file, but I absolutely don't want to use temporary files in this
process. I want to display HTML data directly from the memory stream (or
some other form of memory storage). Is there any control available for C#
that can display HTML data directly from memory?

regards
Tomaz

Nov 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Tomaz Koritnik,

The web browser expects an URL that could be a file or a URL for a internet
resource that is served by some web server. There is no way that you can
pass a memory stream. Of course it depends on the web browser control. If
you use some special control that accepts that then go for it. If you are
using control like IE what you can do is to create a simple ASP.NET
application with a single page. This page can read the name of the web page,
you want to display, as a parameter. The ASP.NET page then can read the
stream and flush its contents to the HttpRespond.Output stream.

For this solution though you need IIS running on the machine. However,
easiest solution would be to save the stream in a file and point the borwser
to it.

HTH
Stoitcho Goutsev (100) [C# MVP]
"Tomaz Koritnik" <no****@nospam.com> wrote in message
news:d8*********@planja.arnes.si...
Hi

I have many short HTML files stored in a binary stream storage to display
descriptions for various items in application. HTML would be display
inside
application using some .NET control or COM control (like Microsoft
WebBrowser). For each description there is one HTML file and along
description text, it contains links to related information. Clicking
related
information would for example open new form in application and display
some
list of items from DB.

When I load HTML data from stream storage, it is stored in memory inside
memory stream. I could display HTML data by first saving memory stream
contents in a temporary file and then instruct browser control to load
from
that file, but I absolutely don't want to use temporary files in this
process. I want to display HTML data directly from the memory stream (or
some other form of memory storage). Is there any control available for C#
that can display HTML data directly from memory?

regards
Tomaz

Nov 17 '05 #2

P: n/a
Hi

Thanks but I know that IE browser does not support displaying HTML files
from memory. IIS is out of the questione and I still don'w want to save HTML
to temporary file :). That's why I'm trying to find some other HTML
displaying component that can do this because I don't know if there are any.
Do you know?

regards
Tomaz

"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Tomaz Koritnik,

The web browser expects an URL that could be a file or a URL for a
internet resource that is served by some web server. There is no way that
you can pass a memory stream. Of course it depends on the web browser
control. If you use some special control that accepts that then go for it.
If you are using control like IE what you can do is to create a simple
ASP.NET application with a single page. This page can read the name of the
web page, you want to display, as a parameter. The ASP.NET page then can
read the stream and flush its contents to the HttpRespond.Output stream.

For this solution though you need IIS running on the machine. However,
easiest solution would be to save the stream in a file and point the
borwser to it.

HTH
Stoitcho Goutsev (100) [C# MVP]
"Tomaz Koritnik" <no****@nospam.com> wrote in message
news:d8*********@planja.arnes.si...
Hi

I have many short HTML files stored in a binary stream storage to display
descriptions for various items in application. HTML would be display
inside
application using some .NET control or COM control (like Microsoft
WebBrowser). For each description there is one HTML file and along
description text, it contains links to related information. Clicking
related
information would for example open new form in application and display
some
list of items from DB.

When I load HTML data from stream storage, it is stored in memory inside
memory stream. I could display HTML data by first saving memory stream
contents in a temporary file and then instruct browser control to load
from
that file, but I absolutely don't want to use temporary files in this
process. I want to display HTML data directly from the memory stream (or
some other form of memory storage). Is there any control available for C#
that can display HTML data directly from memory?

regards
Tomaz


Nov 17 '05 #3

P: n/a
Unfortunately I don't know either. Hopefully the others in the group can
help.
--
Stoitcho Goutsev (100) [C# MVP]

"Tomaz Koritnik" <no****@nospam.com> wrote in message
news:Z4********************@news.siol.net...
Hi

Thanks but I know that IE browser does not support displaying HTML files
from memory. IIS is out of the questione and I still don'w want to save
HTML to temporary file :). That's why I'm trying to find some other HTML
displaying component that can do this because I don't know if there are
any. Do you know?

regards
Tomaz

"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Tomaz Koritnik,

The web browser expects an URL that could be a file or a URL for a
internet resource that is served by some web server. There is no way that
you can pass a memory stream. Of course it depends on the web browser
control. If you use some special control that accepts that then go for
it. If you are using control like IE what you can do is to create a
simple ASP.NET application with a single page. This page can read the
name of the web page, you want to display, as a parameter. The ASP.NET
page then can read the stream and flush its contents to the
HttpRespond.Output stream.

For this solution though you need IIS running on the machine. However,
easiest solution would be to save the stream in a file and point the
borwser to it.

HTH
Stoitcho Goutsev (100) [C# MVP]
"Tomaz Koritnik" <no****@nospam.com> wrote in message
news:d8*********@planja.arnes.si...
Hi

I have many short HTML files stored in a binary stream storage to
display
descriptions for various items in application. HTML would be display
inside
application using some .NET control or COM control (like Microsoft
WebBrowser). For each description there is one HTML file and along
description text, it contains links to related information. Clicking
related
information would for example open new form in application and display
some
list of items from DB.

When I load HTML data from stream storage, it is stored in memory inside
memory stream. I could display HTML data by first saving memory stream
contents in a temporary file and then instruct browser control to load
from
that file, but I absolutely don't want to use temporary files in this
process. I want to display HTML data directly from the memory stream (or
some other form of memory storage). Is there any control available for
C#
that can display HTML data directly from memory?

regards
Tomaz



Nov 17 '05 #4

P: n/a
It is possible to load a HTML string into the AxWebBrowser control. In order
to do this, you first need to navigate the control somewhere so that it will
have the HTML DOM in place. You can then replace the body with your HTML
string. In other words:

- navigate the control to url "about:blank"
- handle the DocumentComplete event like so:

AxWebBrowser browser = ...;
MSHTML.IHTMLDocument2 doc = (MSHTML.IHTMLDocument2)browser.Document;
doc.body.innerHTML = "<body><p>Hello World!</p></body>";

I'm not sure if it is possible to access the header this way, though.

Regards,
Sami

"Tomaz Koritnik" <no****@nospam.com> wrote in message
news:d8*********@planja.arnes.si...
Hi

I have many short HTML files stored in a binary stream storage to display
descriptions for various items in application. HTML would be display
inside
application using some .NET control or COM control (like Microsoft
WebBrowser). For each description there is one HTML file and along
description text, it contains links to related information. Clicking
related
information would for example open new form in application and display
some
list of items from DB.

When I load HTML data from stream storage, it is stored in memory inside
memory stream. I could display HTML data by first saving memory stream
contents in a temporary file and then instruct browser control to load
from
that file, but I absolutely don't want to use temporary files in this
process. I want to display HTML data directly from the memory stream (or
some other form of memory storage). Is there any control available for C#
that can display HTML data directly from memory?

regards
Tomaz

Nov 17 '05 #5

P: n/a
"Tomaz Koritnik" <no****@nospam.com> wrote in message
news:Z4********************@news.siol.net...
Hi

Thanks but I know that IE browser does not support displaying HTML files
from memory.


Actually it does. The details are simple for those who played with the
control low-level (we're talking COM interfaces here) but they've always
been slightly beyond my reach. I remember finding the low-level details in
an open-source project called HtmlEditor:
http://www.itwriting.com/htmleditor/index.php
If you check the source code you'll find that it's all there. You might need
to get rid of some of the additional complexity due to the "editor" bits
that you don't need.

The good news are that in the oncoming version 2.0 of the framework (now in
beta) you'll be able to do this natively because all the relevant interfaces
have been wrapped already. I tried and it just works(tm) :)
--
WildHeart'2k5
Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.