Is there any better web browser control in C# (.NET)? - c#

I need JavaScript working almost perfectly in my application that should be able to access web content and let user take a control of it. However, webbrowser component pops new windows in separate instance / application of Internet Explorer and dotBrowser doesn't work with JavaScript properly.
Please, give me some advice - I'd even take some working example and enhance it with function I need it for.

Give a look to GeckoFX, is on open-source component for embedding the Mozilla Gecko (Firefox) in .NET applications.

I could be mistaken, but I believe new windows can be controlled (or at least suppressed) using the Web Browser control in .NET. Have a look at the NewWindow event.
I have had experience embedding both WebKit (Apple Core, used in Chrome) and XULRunner (Gecko) cores in .NET winforms applications. Let me give you some advice:
GeckoFX is your best bet. It is licensed under MPL and it works pretty much out of the box.
Follow the instructions carefully and pull the exact XUL version that is indicated. I would say it works better than the WebBrowser control. There is some talk of a significant delay when loading XUL for the first time but I've found it to be negligible. Branding and the like is fully customizable via external files.
WebKit is embeddable with SwiftDotNet. If all you need is solid javascript performance then this may be an option. If you need to be able to download files, then you have some work cut out for you.
Your downside with both routes is a nasty ~7-8mb overhead, even with compression (although I was able to get 6.5mb with lz compression in NSIS). If you are not creating distributable consumer-facing software then this may not be a problem for you.

Related

how to create a webbroswer in wpf that supports all the sites and scripts and play video?

I have to create a webbroswer in wpf that supports all the sites and scripts and play video , I have created but some site got crashed and not supporting .
Please provide solution.
What you ran into are probably error dialogs caused by JavaScript script errors. WPF WebBrowser control currently doesn't support disabling these dialogs and ignoring the errors. The WebBrowser control is based on Internet Explorer core and will have a hard time dealing with broken JavaScript, webpages will also sometimes report the web browser as old and inform the visitor about it, like FlipKart does.
One solution is to use WindowsFormsHost and host a Windows Forms equivalent - WebBrowser control - in it. The WF WebBrowser offers a property called SupressScriptErrors, which is not implemented by the WPF WebBrowser. That will hide the error dialogs for you, but you will still occasionaly receive a warning from the website saying they don't support the web browser used. That is out of your control unless you want to take a route of hacking the control to send a different User-Agent string and that will only fool broken UA detection, feature detection will still fail for things like HTML5 video, WebRTC and the like. More on this here.
You can also choose to embed Gecko (Firefox rendering engine) or Chromium. see here for more information on embedding alternative rendering cores as an alternative to IE COM wrapper offered by the framework.
Edit: this is also a possible solution, as it would seem. You will have to test it for yourself, though. I expect it to have less overhead than the WindowsFromHost element and although this uses reflection to develop against implementation, not interface, my opinion is it's safe to say the underlaying API in unlikely to change.

HTML/CSS/JS in desktop applications

I've read about XSS vulnerability in desktop applications like Skype and ICQ.
I wonder why they choose to use html in this kind of applications that can also be written without any html. Is there a simple reason?
Does someone know if Skype uses html on pages like "Skype Home" only or is the whole GUI written in html?
I'm asking because I'm writing a web application that runs within the browser and will be ported to mobile and desktop platforms once finished. You can compare it to instant messengers but it's something different in fact.
I thought about using PhoneGap to simply "copy" the project to mobile platforms and using system functions via the PhoneGap API. But I think it may be slow and/or not good-looking. Also it wouldn't look native, the question then is whether too use our own html GUI on all platforms (so it looks the same everywhere) or to adapt the design concepts of each platform (using native controls in native languages or e.g. Titanium (which is unfortunately too expensive)).
But I never thought about using HTML in desktop applications. How do you embed that anyway? I'm using C#. Using WebBrowser form element or using some kind of web browser rendering engine?
To answer the initial question (in your 1st paragraph):
I assume they chose to wrote it using HTML as a way to make it cross-platform more easily.
You can't make desktop applications using purely HTML/CSS/JS and have them looking native. However you can use Sencha Touch to make your Phonegap applications look native (to an extent).
Mozilla Prism was written with this idea in mind: http://prism.mozillalabs.com/
Have you tried Appcelerator Titanium Desktop/Mobile. They have a similar idea there - http://www.appcelerator.com/
Thanks.
You can use the WebBrowser control to basically host an internet explorer session in your windows application. This is platform specific, but there is a commercial version which is available for some smartphones: http://en.wikipedia.org/wiki/Mono_(software)#MonoTouch_and_Mono_for_Android.
You can make an HTML5 application which will give you a lot of the benefits of a fat client while maximizing portability with smartphones. You can still have the user save the application to the desktop: http://miniapps.co.uk/installation/. But, that's clunky and, like the desbest said, it will run in a web browser. If you want to maximize the customization, then it looks like PhoneGap is an choice worth taking a look at to me as well.

light weight browser control for c# application

is any light weight browser control available for c# application other than builtin web browser control, when i am using IE or Webkit control for embedding it will consumes 80 MB Memory to render a flash website of(800*600 resolution). how can i reduce the memory
EDIT1:
webkit for .net available webkitdotnet.sourceforge.net which is similar to web browser control i am tested it
If you're just trying to embed Flash, This tutorial describes how to do it:
Embedding a flash player control in a.NET winforms application
The key here is to add the "Shockwave Flash Object" COM object to your project. You'll then have a Shockwave Flash Object control in the toolbox which you can drag onto the form. Set the Movie property to the .swf object.
Then you can skip the whole browser.
There is Mozilla embedding available.
Flash as in Adobe Flash? In that case, it's most likely the Flash content that is taking up most of the memory, which means switching rendering engines will do very little to improve memory usage. You're stuck with what you have.
Honestly though, 80MB isn't much at all. Why are you worried about memory usage? Is it a confirmed bottleneck in your application?
Does the website when you open it in IE consume less memory? I doubt that you can improve the memory consumption. It probably is just how much the website needs.
If you simply look for an alternative to the WebBrowser control, you can try the already mentioned techniques but I doubt that you will get better results.
You could try embedding WebKit into a .net app.
You could try Awesomium (yes, the name is slightly /facepalm worthy ;)). It's based on Chrome (which uses Webkit) and is free for non-commercial use (commercial licensing is also available) and there is a CodePlex project called AwesomiumDotNet that provides a .NET wrapper for it.
I haven't used it yet myself, but came across it doing some research into embedding a Webkit-based browser into an .NET/WPF app.

Emulating a web browser

we are tasked with basically emulating a browser to fetch webpages, looking to automate tests on different web pages. This will be used for (ideally) console-ish applications that run in the background and generate reports.
We tried going with .NET and the WatiN library, but it was built on a Marshalled IE, and so it lacked many features that we hacked in with calls to unmanaged native code, but at the end of the day IE is not thread safe nor process safe, and many of the needed features could only be implemented by changing registry values and it was just terribly unflexible.
Proxy support
JavaScript support- we have to be able to parse the actual DOM after any javascript has executed (and hopefully an event is raised to handle any ajax calls)
Ability to save entire contents of page including images FROM THE loaded page's CACHE to a separate location
ability to clear cookies/cache, get the cookies/cache, etc.
Ability to set headers and alter post data for any browser call
Process and/or thread safe would be ideal
And for the love of drogs, an API that isn't completely cryptic
Languages acceptable C++, C#, Python, anything that can be a simple little background application that is somewhat bearable and doesn't have a completely "untraditional" syntax like Ruby.
From my own research, and believe me I am terrible at google searches, I have heard good things about WebKit... would the Qt module QtWebKit handle all these features?
You might try one of these:
http://code.google.com/p/spynner/
http://code.google.com/p/pywebkitgtk/
I know you mentioned you don't like Ruby syntax (neither do I), but I just have to chime in and say that Watir is probably the best thing out there for what you are trying to do.
EDIT: There appears to be a Java counter-part called Watij
I've only been digging into this recently myself, so I couldn't say that this does everything you've listed, but check out GeckoFx.
From the site: GeckoFX is an open-source component which makes it easy to embed Mozilla Gecko (Firefox) into any .NET Windows Forms application. Written in clean, fully commented C#, GeckoFX is the perfect replacement for the default Internet Explorer-based WebBrowser control.
As for my own impressions: it has blown away the default .NET WebBrowser in both performance and stability.

WPF in a browser and printing

Can WPF be hosted in a web browser? If so how? (I think it can as I have seen some examples of it.)
While hosted in the web browser what printing support does it have?
What are the drawbacks to using WPF in a browser?
My company is looking for a rich web app platform. They will not choose Silverlight because it ignores any printing needs (at least as far as I understand). Right now a solution from Adobe is in the lead because it supports printing.
Most (if not all) of the apps written for browsers will be used internally by my company (ie we control the computers and browsers). (We want to use browsers for easy of deployment.)
Have you checked out XBAP (Xaml Browser APplications)?
The major drawbacks I am aware of concern security. When some coworkers of mine were developing an XBAP product, they often ran into problems with security, as the XBAP model is pretty strict.
I can't answer about printing, but I'd tend to think that might be a problem with the security considerations.
Hope I was able to help.
If the apps are solely internal and you control the target platform; and the reason for choosing to host your apps in the browser is 'ease of deployment', I would seriously consider writing Full Trust applications in WPF, and deploying them with ClickOnce... Your users would simply have a shortcut on their desktops that would check a server to see if their version of the app is current, and download the newest version if not.
You get all the benefits of the full WPF platform (greater feature-set than Silverlight), and do not need to conform to the Partial-Trust restrictions of XBAP (although you will need to configure the ClickOnce server to allow for Trusted Application Deployment)
No. That's what Silverlight is for right now and yes there are printing limitations. However, printing anything using a web app is not straight forward.
I would suggest Silverlight/Flex solution for web based app and for printing need the best way to do is use iTextSharp library and generate PDF for your reports or printing need, which can be fetched from a URL. PDF is a very standard and adobe reader will always print it right, printing will not be a problem, we went through lot of options and it requires reinventing wheel where else generating PDF through iTextSharp is very easy as creating normal html in javascript way.

Categories