WebBrowser not loading youtube tv - c#

i have the following URL that doesnt behave in the WPF WebBrowser control as expected. It basically loads only a youtube background image and then stops .. where as firefox/chrome etc. load the youtube view you get on tv-apps.
is there a way to make the WebBrowser load this in the same way?
https://www.youtube.com/tv#/browse-sets?c=UCZGYJFUizSax-yElQaFDp5Q&resume
i tried to parse the same page downloaded with a webclient.. but its also only loading an background page and i dont know how to continue from here.
thanks in advance for any hints

Wpf WebBrowser is a wrapper for IE. If you try to open the link you provided with IE (11 in my case) you can see that it won't work (not supported).
If you change the version of IE that your WebBrowser use (as i described here Script Error in webBrowser control WPF) you can see the not supported page.
You can try using something like https://bitbucket.org/geckofx/ or https://github.com/cefsharp/CefSharp

Related

making WPF webbrowser not accessible for user

maybe it's quite easy question, but I haven't managed to find a solution. I'm using web browser only to display data, and don't want user to access shown webpage. I know that in win forms' webbrowser it's possible, but how can I achieve it using WPF control?
PS I don't want to lock browser action in the navigate event, as described here: How can I make a WPF WebBrowser read-only? , because this won't stop my user from running javascripts etc
PPS And I also don't want to disable js, because I want it to be used by webpages. What is more, I'm executing it from code, as long as navigating between sites
Add this to Windows_Loaded Event
webbrowser1.IsEnabled = false;

Take screenshot of div in InternetExplorer

I am using mshtml.InternetExplorer object within my winforms application to browse a web application. Somehow I can't use webbrowser in my solution. Now I need to capture screenshot of a div element inside this web application. I see lots of solutions doing similar functionality using webbrowser's drawtobitmap method but none is using mshtml.InternetExplorer.
Is there way to achieve this functionality ? Is there some way that I can type cast InternetExplorer object into webbrowser?
You should be able to capture the desired part of the main IE window using PrintWindow Windows API, as explained here. You can get the handle of the window by calling IWebBrowser2::HWND on the IE object. Some other methods could also help to make this happen:
IWebBrowser2::ClientToWindow
IHTMLElement::scrollIntoView
IHTMLElement2::getBoundingClientRect

Display Custom Dialog When File Downloaded

Looking for a solution to my issue. We are building a web browser control into a product for a client, they need to be able to detect when there is a File Upload box on a website, then instead of it launching the Windows 7 File Browser window, it needs to open their own custom designed one
Is there a browser event that allows us to capture that?
You can hook up your own download manager that is effective only in your webbrowser control host process by implementing IServiceProvider in the control site and implement QueryService to return an IDownloadManager object when asked by the webbrowser control
In Windows Form's Webbrowser class, a control site is created for you by default, but you can override the control site by create your own WebBrowserSiteBase class and override the WebBrowser.CreateWebBrowserSiteBase Method. There is no such extensibility if you use the webbrowser control from WPF, Silverlight or Windows Phone.
I suggest you write the download manager in C++ due to the amount of interop required if you code in C#. There's an example for a C# webbrowser control using a native download manager here.
You can catch the FileDownload event, and handle it yourself.
See http://msdn.microsoft.com/en-us/library/bb268220(v=vs.85).aspx
After showing your custom file dialog, send the data back to the webbrowser control, and submit the form.
Another option is to inject javascript into the control. Inject a code that replaces the call from the upload button, and show a form of your own instead.
So you want to modify the value of <input type=file .... You cannot do that with webbrowser control because it accesses DOM like javascript, vbscript vs. And if DOM allowed accessing and changing the uploaded file bad guys could easily steal your local files (using javascript) when you visit their pages.
Furthermore you can't even see the value of FileUpload because of that security issue.
If you want to select a file programmatically that is possible with a combination of SendKeys

Webbrowser and IE acts differently?

I'm in a trouble trying to fix some problem.. I have a program with Webbrowser control inside it.
It automates crawling process from some website. The problem is that I cannot fix webbrowser after recent website changes.
They have changed page navigation on website. And when I do actions MANUALLY in webbrowser (in my app) it doesn't go to the next/previous page on website. It does nothing... Whereas it works properly in IE 7/8/9 (only scripting errors thrown this time).
So does it mean that Webbrowser is not fully similar to IE??
I'm sorry for not showing source codes here, I think it wouldn't help here. Which way should I go to troubleshoot it? Why page navigation is not working in Webbrowser control?
I tried to simply put Webbrowser on a Window Form in new project and tried to navigate page 2/3/../10 in the website catalog, but it simply changes page number and doesn't navigate to it...
EDIT: Website doesn't work propely even if I do actions manually in webbrowser using mouse clicks.. but works in IE.
EDIT2: I might be not clear in my question. The problem is that I cannot use website even Manually with mouseclicks via my Webbrowser control in app. It changes page number after I click on it, but it doesn't navigate to that page. It stays silent. I'm sure that AllowNavigation property is true. It worked just yesterday and stopped after website changes today... Please tell me which way should I go to troubleshoot it.. I thought that Webbrowser control acts the same way as Internet Explorer.. Any help from you highly appreciated! Thanks
EDIT3: Strange thing... i just loaded Extended Webbrowser and navigated to that website. Page navigation panel doesn't work there also.. Is it a bug on their side or some type of guard from crawlers? What do you think?
(http://www.codeproject.com/KB/cpp/ExtendedWebBrowser.aspx)
I'm sure this isn't the answer your want but using the webbrowser control to scrape websites is very painful to maintain.
Instead use the HttpWebRequest and HttpWebRepsonse objects to recreate the calls to the webserver.
You can use Fiddler (http://www.fiddler2.com/fiddler2) and your browser to record your web sessions and recreate them in code.
You can setup your webbrowser control to disable a number of features including navigation.
I.e. to disable nav in the C# WebBrowser control:
webBrowser1.AllowNavigation = false;
I'd double check that you're not doing anything like this.
I had the same issue with a certain web site that recently changed its format. It has to do with the version of IE used by the control.
Simply force the IE version used to the latest (in my case 9). Setting the appropriate registry item to 9999 for my application worked; see: Webbrowser control behaving different than IE

How to add IFRAME in SilverLight?

How do I add IFrame in a Silverlight 4.0 User control ?
And I want a button on the control that refreshes the IFrame. Is that possible?
To render HTML on top of silverlight, you have to use WindowLess mode. This is a configuration in the object tag. Then you'll need to manually program your IFrame to float in the correct location using javascript or the bridge provided by Silverlight. You can use a commercial control like Robaticus suggested or figure it out on your own.
Either way, none of these options work for Mac. So if you're developing for Windows only, then you're ok. Anyone using Mac will not see any HTML float on top of Silverlight.
If you absolutely want an IFrame in the HTML page (contrary to what the other answers suggest) you could obtain access to the IFrame in Silverlight by using the HTML Bridge
I think you can use WebBrowser class to display IFrame content in Silverlight. Or check this link it will also help you. - How to use iFrame tag in XAML Silverlight 4?
The iframe tag is HTML, not Silverlight. If you have an out-of-browser Silverlight application, you could potentially use the WebBrowser control, but this is not available for in-browser applications.
There is an approach out there where you can essentially make a DIV on your hosting page appear overtop of your Silverlight application, but, in my experience, this is very hard to control, and the visual results are less-than-ideal.
Additionally, there are a few commercial components that do HTML rendering, but they all seem to use the same approach of a floating DIV, and they are not as reliable as I would like to see them.

Categories