Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8090151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:37:36+00:00 2026-06-05T19:37:36+00:00

I believe I am having a security problem related to using the embed tag

  • 0

I believe I am having a security problem related to using the embed tag with a WebBrowser control in my C# 2008 WinForms application.

Here is my code:

private void button2_Click(object sender, EventArgs e)
{
    webBrowser1.Navigate("C:/page1.html");
}

private void button1_Click(object sender, EventArgs e)
{
    webBrowser1.Navigate("about:blank");
    Thread.Sleep(1000);
    webBrowser1.Document.Write("<html><body><p>Hello</p><embed src='C:/test.wmv' /></body></html>");
}

This is the contents of page1.html:

<html><body><p>Hello</p><embed src='C:/test.wmv' /></body></html>

Button1 generates the word “Hello”.
Button2 generates the word “Hello” with an embedded movie player below it.

When I view the sources for both pages I notice they are identical, except for the name of the source file.

This leads me to believe it is something to do with my IE security settings, but I notice that I have full permissions set for embedded content. Perhaps the control doesn’t recognize the source of the page as proper and therefore doesn’t allow the embed tag to be used.

How can I overcome this programatically? I want to avoid writing my page to file, and navigating to that file at all cost. Any suggestions on how to trick the browser control into working properly?

1st Editor:

According to this article Webbrowser Navigate Embedded Resource this will work, but I (JT) tried and it didn’t:

System.IO.Stream stream = this.GetType().Assembly.GetManifestResourceStream("WindowsFormsApplication1.Properties.test.html");
webBrowser1.DocumentStream = stream;

Odd behavior while reproducing problem:

webBrowser1.Navigate("about:blank");
do
{
Thread.Sleep(100);
} while (webBrowser1.IsBusy == true);

//Method 1. Doesn't work
string htmlString1 = File.ReadAllText("C:/page1.html");
webBrowser1.Document.Write(htmlString1);

//Method 2. Doesn't work
string htmlString2 = "<html><body><p>Hello</p><embed src='C:/test.wmv' /></body></html>";
webBrowser1.Document.Write(htmlString2);

//Method 3. DOES WORK
webBrowser1.Document.Write("<html><body><p>Hello</p><embed src='C:/test.wmv' /></body></html>");

Edit 2

Here is an example of a page created with JavaScript, with no real source file, that does display the embedded player in IE:

<html><head>
<script language="JavaScript">
function go()
{
test1 = window.open("","","menubar=0,status=0,toolbar=0");
test1.document.writeln("<html><body><p>Hello</p><embed src='test.wmv' /></body></html>");
}
</script>
</head><body><h1 onclick="go()">click</h1></body></html>

The only difference here is that IE thinks the source of the HTML is a file, although, it is created by “writeln”.

While it is popular opinion that IE does not support the tag, it does, and there are many examples proving it. Attempting with IE on jsfiddle.net in IE will yeild an embedded player, while in FF it will not.

Edit 3

This issue is related to cross-domain security. Not only do the newer versions of IE refuse to allow any changes to the domain of a page once it exists, the WebBrowser control doesn’t let you write text to a document that already has text in it. Only the first call to Document.Write does anything. Not only is there no apparent way to force the domain of page, there is also no way to write anything new to a page with a domain that is set because “openNew”, which is required in order to do any writing, opens about:blank and defaults to a null domain that causes exceptions if set or get is attempted.

Edit 4

The issue lies in Cross-Domain security shenanigans. See THIS IE8 decided that Document.Domain can’t be written to. Even if it were writable, you can apparently never communicate between protocols. So the “file://” protocol, and the “about” protocol can’t communicate, or have tags pointed at one another. Here are the stumbling blocks:

  • The version of IE used by the Browser Control can’t do anything to
    Document.Domain, not even with JavaScript.
  • You can’t read the domain of about:blank.
  • You can’t load a page with the proper domain, and expect to use
    Document.Write to write HTML into it, because you are forced to call
    Document.OpenNew before using Document.Write.
  • You can’t modify the DocumentText by using WebBrowser.DocumentText =
    anything because you can only set DocumentText once per navigation. This is like some other security thing.

In conclusion, it is sufficient to say that you don’t have any extra control over security with the WebBrowser control, likely even less than you have with some JavaScript generated pages (because these pages share the domain of the launch script).

Thanks for the votes/support in my endeavor, but it looks like I’m going to give up and write a page to file every time I want to change what is in the browser control. Yuck.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:37:38+00:00Added an answer on June 5, 2026 at 7:37 pm

    The issue lies in Cross-Domain security shenanigans. See THIS IE8 decided that Document.Domain can’t be written to. Even if it were writable, you can apparently never communicate between protocols. So the “file://” protocol, and the “about” protocol can’t communicate, or have tags pointed at one another. Here are the stumbling blocks:

    • The version of IE used by the Browser Control can’t do anything to
      Document.Domain, not even with JavaScript.
    • You can’t read the domain of about:blank.
    • You can’t load a page with the proper domain, and expect to use
      Document.Write to write HTML into it, because you are forced to call
      Document.OpenNew before using Document.Write.
    • You can’t modify the DocumentText by using WebBrowser.DocumentText =
      anything because you can only set DocumentText once per navigation. This is like some other security thing.

    In conclusion, it is sufficient to say that you don’t have any extra control over security with the WebBrowser control, likely even less than you have with some JavaScript generated pages (because these pages share the domain of the launch script).

    Thanks for the votes/support in my endeavor, but it looks like I’m going to give up and write a page to file every time I want to change what is in the browser control. Yuck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe I am having a memory issue using numpy arrays. The following code
I'm having trouble within a block of code that I believe is related to
Alright, I'm having some issues and I believe it's a CSS one. Here is
I can't believe I am having this problem. I've been looking and looking but
I am having a slight problem. I believe that my Netbeans is set to
I'm having a problem and believe something simple, just can't get a grip on
I am having trouble identifying a problem on Android TimerTask (I believe) that is
I'm having difficulty with a Flex app I'm creating. I believe the problem is
I'm having a problem with IE only in my Silverlight application. Since Silverlight 2
I'm having a problem that I believe has a simple solution. I'm writing a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.