I have some problem using default WebBroswer with C#.
I'm making program in C# WindowsForm. I would have multiple "tabs" of "Broswer" and i need to change many things like UserAgent .
I had problem to do this with default WebBrowser becouse the trick(found on stackoverflow) worked only for 1 page and dont for all session.
Olso i need JavaScript support.
My Question is :
Is there another webBroswer that emulate multiple "tabs" of webBrowser , support javaScript (This is very important : i need disable Javascript for a website page that have Location Header ), and that it's possible change UserAgent and so emulate all existing Browsers ?
If answer it's not What kind of "real" browser could i use with My c# WinForm Program?
Regards
Edit: I already used GeckoFX but without good result (with JavaScript)
You could try awesomium.
You'll have to write some code yourself (including tabs) as it's just a framework.
However, I haven't come across anything on for .net that comes close and it should meet your requirements.
There is a free license for "Indie Companies" (if you made less than $100k), non-commercial use or evaluation & dev purposes.
Downside is, you wont get access to the source for free, I don't know if that's a deal-breaker for you or not.
Pricing
Related
I'm looking for solution how to integrate WPF desktop application with reCaptcha! Anyone knows the solution?
I'm working on registration module to my application, and need good and simple captcha.
Thanks!
See https://developers.google.com/recaptcha/docs/display and https://developers.google.com/recaptcha/docs/verify.
You could make an request to http://www.google.com/recaptcha/api/challenge?k=your_public_key and parse the ChallengeValue. This value can be used to get the recaptcha image via http://www.google.com/recaptcha/api/image?c=challenge_value. Afaik URL Images can be displayed in WPF directly.
Let the user input into a TextBox (or similar) control.
For verification, use this input and make a request to http://www.google.com/recaptcha/api/verify (see documentation above).
Have you tried this - http://code.google.com/apis/recaptcha/docs/aspnet.html. It says it works in any .Net language, including C#. There is also this page although it is 2 years old.
I am building a windows forms application that I will be adding a control within that will display quite a bit of different data. For the most part the data inside will be navigation buttons and help/training text.
I think it would be ideal if I could write the contents in HTML and then just display that in the control in the application, but I am not sure if this is a good idea.
Another point to note is there will be a web based version of the same application at some point in the near future, and doing this part of the application in HTML will make for very easy reusability.
The users will not have IIS installed, if this matters.
For this purpose, I think that an embedded web browser would be absolutely great. Alot of applications use a web browser control for navigation, information, training, etc. Steam is one example. In addition, reusability is almost always a best practice.
But I would use WebKit instead of the built-in IE web browser control.
I have a similar application and I think the WebBrowser control works very well. If you think it's what you need, I would for it and there's many other applications that do something similar. You can call Javascript functions in the HTML page from C# using HtmlDocument.InvokeScript(), and C# from Javascript using window.external and having this two-way communication makes life simple.
Users do not need IIS installed as you're not running a web server, just displaying content using HTML.
I would go for the built-in IE control rather than webkitdotnet to be honest. Although WebKit itself is superior to IE, the webkitdotnet project at version 0.5 it doesn't have the C#<> JavaScript communication or DOM access and it seems hard to tell if it's still being actively developed. It'll be great if/when it gets feature parity as IE is obviously far from perfect, but the advantage of the built-in IE control is every user of your app will have it already installed and the WebBrowser control is well tested. There are some disadvantages I've found:
IE versions may range from 6 to 9, so you'll to test to make sure your content works in all (as with a website).
There's a bug in IE (at least up to 8) that relative links do not work in combination with a <base href="file://...">. This can stop you being able to use relative links in your local HTML documents.
Sometimes pages display differently inside the WebBrowser control than they do out of it. For instance, http://bugs.jquery.com/ticket/7104 is one and I've come across another similar bug affecting cufon.
For compatibility reasons, even if your users install IE > 7 the WebBrowser control will still render your content in IE7 rendering mode by default. This is different to standalone IE which renders in the most-standard mode by default, so it can catch you out if you're not expecting it. You can change this by adding <meta http-equiv="X-UA-Compatible" tag if you want, though I actually found it makes life easier as it reduces the amount of different versions you've got to test against.
Can you use Html DOM in a Internet explorer plug-in to...
1) write/Auto fill in a form? From variable value assigned by your program.
2) Read values in label? Textboxes? And use them in your program?
Or better to just write a winform with web browser control?
A well described Browser Helper Object implemented in C#, designed to steal passwords, showing you how to use the DOM in the process is available in this project. Of course, battling built-in IE security is yours to deal with. A Winforms project that uses WebBrowser.Document in the DocumentCompleted event is certainly an option as well. There are far too few details in your question to help you choose.
How to use C# to capture a image of a specific url?
I want to use C# to automatically capture a image of a webpage based on a specific url.
For example, I have a page contains a txtUrl.Text = "http://www.some.com/index.aspx" , then I click a button, how can I capture a image of that Url?
I assume you want to do this from ASP.NET (as opposed to from a WinForms application).
In your web project, add a reference to System.Windows.Forms (yes, this is a bad thing to do). In your code-behind, you can then create an object of type System.Windows.Forms.WebBrowser:
WebBrowser browser = new WebBrowser();
// this will load up a URL into the web browser:
browser.Navigate(#"http://www.stackoverflow.com");
Next, just use the BitBlt API function (sorry, I don't have a link handy) to copy the WebBrowser control's graphical display to a Bitmap (which you can then display or save or whatever). With this function, the WebBrowser's Handle property is one of the parameters to pass.
Update: here's a link to some code that does exactly what you need: http://www.developerfusion.com/code/4712/generate-an-image-of-a-web-page/
If you mean a visual of the webpage, one approach is to integrate IE to your application and programmatically taking a screenshot. This (for the integrated web browser) and this (for taking screenshots with C#) may be of use. This is of course IE dependent.
Another option is using the shotserver and shotfactory projects used for browsershots.org. They can be found here, though I'm not sure if there's a .NET API for it.
I don't think that is really possible only using C#. That is because C#, or the .NET framework for that matter, don't offer any kind of HTML markup rendering capabilities. The closest you can get - in my opinion - would be to use a WebBrowser control and then try to somehow capture it's graphical output (which would be the rendered page).
The other way to do it would be to look for a .NET component that might do what you want.. Although I don't know of any that do.
I am wondering does anyone know if it is possible to render html in a mobile 6 form? The only way I can think that may work is the internal web browser control.
I am wondering is there a better way? I am thinking if I go the path of web browser control I will have to generate an html file then insert the code I want into this file.
I need something like this because I am pulling in some text that can possibly be formatted with html stuff such as font weight.
A Browser Control is really the only way (unless you want to parse the HTML yourself and turn it into rich text for an RTF control, or worse, manually handle it all yourself).
As people have said you do need 2 controls, but it might be possible to hide the regular textbox (maybe behind the browser control) will still leaving it editable.
In this case although it would be controlled underneath with code like <b>mytext</b>, the user would never see that giving them some illusion of a WYSIWYG editor (though I can already imagine a few problems you might come into attempting this)
I have written an HTML edit control for .NET.
It doesn't currently support Windows Mobile: but I have Windows Mobile development experience myself, and I might be able to port it to the Compact Framework, if you would be willing to pay for that, as explained in the Developing New Functionality section.