Display html containing iFrame in Windows Form c#

2019-09-04 08:12发布

问题:

i am creating a window application as well as a web application using c#. Scenario is like below:
1. Admin will post messages using Wysiwyg editor( i am using tinyMCE) from the website
2. User will have windows form that will be download the message and display it on the form.
I have taken a webBrowser control to display it. its working fine to display html( formatted text along with picture). problem occurs when we want to display video on it.

I am using following code for that: webBrowser1.Navigate("about:blank");

            HtmlDocument doc = this.webBrowser1.Document;
            doc.Write(String.Empty);
            string strHTML="<p><iframe src="http://www.youtube.com/embed/xXdDjnVM1kI" frameborder="0" width="425" height="350"></iframe></p>\r\n<p><span style="color: #ff0000; font-size: xx-large;">Hi, </span></p>\r\n<p><span style="color: #33cccc; font-size: large;">Enjoy Ganganam Style</span></p>\r\n<p> </p>";
            string strDecoded=System.Net.WebUtility.HtmlDecode(strHTML);             
            webBrowser1.DocumentText = strDecoded;

Its showing me security alert while running it:

When i add these sites in the trusted site, it works fine. but i want to get ride of these security warning. for that i have tried webBrowser1.ScriptErrorsSuppressed = true;, but its not working also. and also tried How to programmatically answer "Yes" to WebBrowser control security alert.
When webBrowser1.ScriptErrorsSuppressed = true; then iFrame come like below: But i have Adobe Flash Player, and i can play the video by adding the warning site in the trusted sites manually.

Is there any option to avoid these and play the video? any kind of help and suggestion is appreciated.

回答1:

You can fix this by disabling enhanced security or by adding the page to the trusted zone.