HtmlDocument.Domain Property

 

Gets or sets the string describing the domain of this document for security purposes.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public string Domain { get; set; }

Property Value

Type: System.String

A valid domain.

Exception Condition
ArgumentException

The argument for the Domain property must be a valid domain name using Domain Name System (DNS) conventions.

By default, two Web pages in different frames are prevented from accessing each other's content using script; even www.microsoft.com and msdn.microsoft.com are, in this instance, considered different domains. To enable cross-frame scripting for pages from the same top-level domain, you can assign a new value to the Domain property. In the pervious URL example, setting Domain to microsoft.com would allow both pages to communicate with one another.

Strings assigned to the Domain property must be valid top-level domains. In the previous URL example, you can set Domain to microsoft.com, but not to .com, which would enable any page on the Internet to script a page's contents.

You cannot use the Domain property to enable cross-frame scripting for pages accessed using two different protocols. If one frame in your page comes from a Web server (the http:// protocol) and another comes from the file system (the file://) protocol, they will not be able to communicate with one another regardless of the value of the Domain property.

.NET Framework
Available since 2.0
Return to top
Show: