WebBrowser.Source Property

Definition

Gets or sets the Uri of the current document hosted in the WebBrowser.

C#
public Uri Source { [System.Security.SecurityCritical] get; set; }
C#
public Uri Source { get; set; }

Property Value

Uri

The Uri for the current HTML document.

Attributes

Exceptions

The WebBrowser instance is no longer valid.

A reference to the underlying native WebBrowser could not be retrieved.

Navigation from an application that is running in partial trust to a Uri that is not located at the site of origin.

Examples

The following example shows how to configure WebBrowser to navigate to an HTML document by using markup only.

XAML
<!-- Web Browser Control that hosts a web page. -->  
<WebBrowser x:Name="webBrowser" Source="http://msdn.com"   
  Width="600" Height="600"  />  

Remarks

Setting the source property causes WebBrowser to navigate to the document specified by the Uri. If the Uri is null, a blank document is displayed ("about:blank").

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10