Home > Back-end >  VS2019 WinForm app with webbrowser control
VS2019 WinForm app with webbrowser control

Time:10-01

I have a VS2019 WinForm app with a form that contains a webbrowser control. The URL for the webbrowser control points to a form on my asp.net web site, HelpForm.aspx. The URL for HelpForm.aspx has args that the aspx page can use in the code file to make a database call with the args supplied to fetch text/html from a SQL Server database then apply that text/html as text to a label on the aspx page. That aspx page is then returned to my webbrowser control on my winForm. That all works fine. This allows me to use the same forms to retrieve different help data from the database.

As part of the text/html stored in the database some of the records contain code to embed a YouTube video. Here is an example of what is in the database:

'... The same is true if you use the mouse wheel while a combo box has the focus.

<object width="560" height="315"><param name="movie" value="https://www.youtube.com/embed/fpXX8mSuDV4"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://www.youtube.com/embed/fpXX8mSuDV4" width="560" height="315"></embed></object>

Note: There is a ....'



On some machines this works and the video appears inline with the text but on others I get a black box or a white box with a tiny icon in the upper left corner.

This seems to have something to do with IE/Edge but I cannot find anything useful to help fix this.

Any ideas ?? Thanks

CodePudding user response:

The WebBrowser control is stuck in IE7 mode by default, unless you edit the registry on every computer where your application runs.

But even if you can edit the registry, you'll still be using Internet Explorer. And YouTube dropped all support for Internet Explorer back in March 2020.

Unfortunately, you're going to need to update your application to use a more modern browser control. For example, either CefSharp or WebView2 should work.

  • Related