Let me be a bit more specific.

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I am using an embedded resource(".aspx or .HTM") which is then extracted
from the for the Assembly like I have shown below.

stream = assem.GetManifestResourceStream(resourceName)

This stream I want to output to the browser in a open new window call
generated from the code behind.

Any help would be greatly appreciated.
 
Chris,

Doing this is a little complicated. What you have to do is implement
the IMoniker interface exposed through COM. Fortunately, this is exposed
through the System.Runtime.InteropServices namespace through the
UCOMIMoniker interface.

When implementing, there are really only two methods you have to worry
about. The first is GetDisplayName. You will want to implement this so
that it returns the base url that the resource is coming from. For your
HTML page, it might not matter, but if you have a stream you saved from some
other site, and still want the links to point to the other site when you put
this content in the browser, then this is where you have to return the
original URL it was downloaded from.

The second method you have to implement is BindToStorage. For MSHTML,
this method is going to be called requesting an IStream implementation (you
can ignore the others). You will have to implement the IStream interface
and then return that. The IStream implementation will have to just call the
methods on the Stream instance that you want to read from.

Once you have that, you then have to get the IPersistMoniker interface
that MSHTML.HTMLDocument implements. You can then call Load on that
interface, passing in your implementation of UCOMIMoniker, and it will get
the data from your stream.

Hope this helps.
 
Will this work? The stream contains the page and there isn't an actual
URL...

Do you have any samples of how to do this?
 
Chris,

Using the technique I described before, it is possible. If you don't
have a base URL, that's ok, you can just return an empty string for the
GetDisplayName method implementation on UCOMIMoniker.

It requires a little bit of work, but shouldn't be too hard.
 
Back
Top