0

I would like to manually load HTML into a web browser control and make sure it does not create any internet traffic, so just show the content to the best of its abilities.

As specified in MSDN, WebBrowser.IsOffline is read-only.

Is there a way to set it (without using reflection hacks)?

Or do I have to resort to using a 3rd party control for this:

Victor Zakharov
  • 25,801
  • 18
  • 85
  • 151
  • 2
    If you do go with a third party control, dont use the one you linked, try this - http://htmlrenderer.codeplex.com/ – EkoostikMartin Aug 25 '14 at 14:59
  • @EkoostikMartin: Thanks for the link, I especially like this part: **100% managed C# code**, the one I found is written in C++ and thus requires a `regsvr`. Not a deal breaker, but being biased towards managed code, I will consider using it if no other options are posted. You can post it as an answer - I will definitely upvote it. – Victor Zakharov Aug 25 '14 at 15:06
  • Do you want to use IE cache? – spongebob Aug 25 '14 at 16:23
  • @Joiner: No, I will be supplying the HTML manually. – Victor Zakharov Aug 25 '14 at 17:00
  • @Joiner: I was looking for a way to safely display the web page, without it going to the internet and downloading more stuff. – Victor Zakharov Aug 26 '14 at 11:03

1 Answers1

1

You can set WebBrowser.AllowNavigation to False.

Whether the control can navigate to another page after its initial page has been loaded.

spongebob
  • 8,370
  • 15
  • 50
  • 83
  • I keep getting errors similar to this one: http://snag.gy/fewZq.jpg, ScriptErrorsSuppressed seems to help, but I'm still not sure if it's doing any external requests in order to load. For example, if there is a Java call, such as a redirect to another page, would it fire? – Victor Zakharov Aug 25 '14 at 18:23
  • Can I virtually cut the wire for the web browser control? It should always appear as offline, even if network is available for the rest of application. – Victor Zakharov Aug 25 '14 at 18:42
  • Interesting, but would probably not prevent ajax callbacks, i.e. dynamic HTML. I'll check it out later in the day though. +1 but leaving unaccepted in case anyone else has other ideas. Don't worry though, if nobody else provides input within 24 hours, I will accept it then. – Victor Zakharov Aug 25 '14 at 19:03
  • Setting `DocumentText` together with `AllowNavigation = False` seems to very close, i.e. a redirect is successfully blocked `WebBrowser1.DocumentText = ""`. I would, however, prefer to disable JS popups if there are any, so the user can just see content. Stuff like this: `WebBrowser1.DocumentText = ""` Unfortunately, [there is no way to disable JS in a client application](http://stackoverflow.com/a/10623739/897326). I will probably use a 3rd party HTML renderer then. Accepting your answer... – Victor Zakharov Aug 26 '14 at 14:44