Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Webbrowser mht file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CJ - 28 Feb 2008 00:02 GMT
After you trigger your event and store an internet webpage as an .mht file,
then you store the contents of the .mht into a database.  Has anyone figured
out how to load the contents from the db into a webbrowser, and have it
display the same way with all the embedded pictures and everything?

I have been reading posts for days, but it seems there is no answer to this
question.

If you download a webpage into an .mht file and you double-click on the
file, it opens up fine in IE.  But what is the trick in getting it to
display the
same way from a string, or a blob stream from a db.
Kalpesh - 28 Feb 2008 04:59 GMT
Note: I have not worked with mht files & loading them programatically
from database/string.
However,  it is just a file

So, if you have stored it in a db, you can retrieve the content in
form of a string.
Create a temporary mht file with those contents on your filesystem &
open that file using Process.start <path to the mht file>

Does that help?

Kalpesh
CJ - 28 Feb 2008 12:46 GMT
Kalpesh,

Doing it like that will work, but I really would like to display it from the
db and not by creating
and deleting a temp file.

> Note: I have not worked with mht files & loading them programatically
> from database/string.
[quoted text clipped - 8 lines]
>
> Kalpesh
Kalpesh - 29 Feb 2008 00:15 GMT
From what I understand, it will require a file to be shown in the
browser.
It could be a case where the browser hosted inside the application
doesn't show the address bar.

Try using process explorer to see what files are opened by the
application.

Kalpesh
Mufaka - 28 Feb 2008 05:31 GMT
The problem is that images are loaded using subsequent requests by the
web browser. So are javascript and css files.

IE knows how to handle these subsequent requests by using a different
protocol to fetch the named resource from the mht file.

For example, viewing the properties on an image gives me the following:

mhtml:file://C:\Temp\Google.mht!http://www.google.com/intl/en_ALL/images/logo.gif

So, I think you are just going to have to write to a temp file and
navigate to it.

> After you trigger your event and store an internet webpage as an .mht file,
> then you store the contents of the .mht into a database.  Has anyone figured
[quoted text clipped - 8 lines]
> display the
> same way from a string, or a blob stream from a db.
CJ - 28 Feb 2008 12:45 GMT
I wish it worked like that, but it does not.  Once you change the file
extension from
.mht to anything else, guess what it does not work.  It has to have an .mht
file
extension for it to work.  I tried it and was truly disappointed at the
results.
I have seen other programs save and load the entire page from a database,
but I have no clue on how they are doing it.

> The problem is that images are loaded using subsequent requests by the web
> browser. So are javascript and css files.
> So, I think you are just going to have to write to a temp file and
> navigate to it.
Mufaka - 28 Feb 2008 18:21 GMT
I don't think I suggested that you change the file extension. Perhaps I
wasn't clear enough.

You are *probably* never going to be able to render the web page
straight from the database if it is in mht format or contains images, js
files, or css files.

The rendering of html will make additional requests for images, js
files, and css files. If you don't have somewhere to fetch those that
the browser can get to, it won't work.

> I wish it worked like that, but it does not.  Once you change the file
> extension from
[quoted text clipped - 9 lines]
>> So, I think you are just going to have to write to a temp file and
>> navigate to it.
CJ - 28 Feb 2008 23:42 GMT
Is there such a thing as rendering the images inline and store them into the
html file?

Something like a resource file that stores everything in gibberish, but when
you
load it, you can see the pictures etc.

>I don't think I suggested that you change the file extension. Perhaps I
>wasn't clear enough.
>
> You are *probably* never going to be able to render the web page straight
> from the database if it is in mht format or contains images, js files, or
> css files.
Mufaka - 29 Feb 2008 04:45 GMT
Not that I know of. MHT is pretty good if you can get past not wanting
to have it read from a local file.

I understand that you don't want to have to manage those files, but you
might also want to consider that you are probably going to want some
caching mechanism for these anyways depending on your database.

Also, consider that if you use Navigate, you will be able to use the
built in Back/Forward to page through previously loaded pages.

It doesn't seem too terrible to have an application folder sub-directory
to write these files from the database. When the application fetches an
mht from the database, it can create the directory if needed and write
the file there. When the application exits, it can just remove the
directory.

Another approach might be to tackle this from the MIME perspective. You
can parse these files with a MIME parser so you may be able to figure
out how email clients render emails with html bodies.

Regardless, when I come across situations like these, I typically use an
approach that I know how to get working and move on. I create an
Interface for it where I can easily swap out the behavior with another
implementation if a better solution can be found.

> Is there such a thing as rendering the images inline and store them into the
> html file?
[quoted text clipped - 9 lines]
>> from the database if it is in mht format or contains images, js files, or
>> css files.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.