Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

WebBrowser.Source Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public Uri Source {
	[SecurityCriticalAttribute]
	get;
	set;
}

Property Value

Type: System.Uri

The Uri for the current HTML document.

Exception Condition
ObjectDisposedException

The WebBrowser instance is no longer valid.

InvalidOperationException

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

SecurityException

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

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").

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

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

.NET Framework
Available since 3.0
Silverlight
Available since 4.0
Return to top
Show:
© 2017 Microsoft