0

Using Developer Tools in IE or Chrome, I get html code for a frame. No problem.

Now, I want do it using C# application. I have System.Windows.Form.WebBrowser in VS2010. I try get Html code for a Frame.

 public static HtmlElementCollection GetElementsByTagNameForFrame(this WebBrowser wb, 
                                             string tag, string idFrame)
 {
      return wb.Document.Window.Frames[idFrame].Document.GetElementsByTagName(tag);
 }

but I get error UnauthorizedAccessException.

I try again like this Read HTML code from iframe using Webbrowser C# but I get the same error.

string content = doc.Window.Frames["injected-iframe"].WindowFrameElement.InnerText; 

Any suggestions ?

Community
  • 1
  • 1
Kiquenet
  • 14,494
  • 35
  • 148
  • 243

1 Answers1

0

You didn't write it, but i assume that the iFrame includes content from different domain. Modern browsers includes some anti-XSS mechanism, like this, to give attacker more work.

In that case, the most easy way is to check what's showing inside the iFrame, and then manually download the web page that inside using WebClient. if it's some kind of members area, you might have to copy the cookies. so, just get the src attribute of the iframe and use WebClient.DownloadString to download this page.

Shahar Gvirtz
  • 2,418
  • 1
  • 14
  • 17