WebBrowser.Refresh Method

Definition

Reloads the document currently displayed in the WebBrowser control.

Overloads

Refresh()

Reloads the document currently displayed in the WebBrowser control by checking the server for an updated version.

Refresh(WebBrowserRefreshOption)

Reloads the document currently displayed in the WebBrowser control using the specified refresh options.

Refresh()

Source:
WebBrowser.cs
Source:
WebBrowser.cs
Source:
WebBrowser.cs

Reloads the document currently displayed in the WebBrowser control by checking the server for an updated version.

C#
public override void Refresh();

Examples

The following code example demonstrates how to use the Refresh method to implement a Refresh button for the WebBrowser control similar to the one in Internet Explorer. This example requires that your form contains a WebBrowser control called webBrowser1 and a Button control called ButtonRefresh.

For the complete code example, see How to: Add Web Browser Capabilities to a Windows Forms Application.

C#
// Reloads the current page.
private void refreshButton_Click(object sender, EventArgs e)
{
    // Skip refresh if about:blank is loaded to avoid removing
    // content specified by the DocumentText property.
    if (!webBrowser1.Url.Equals("about:blank"))
    {
        webBrowser1.Refresh();
    }
}

Remarks

The WebBrowser control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. The Refresh method forces the WebBrowser control to reload the current page by downloading it, ensuring that the control displays the latest version. You can use this method to implement a Refresh button similar to the one in Internet Explorer.

Note

A document refresh simply reloads the current page, so the Navigating, Navigated, and DocumentCompleted events do not occur when you call the Refresh method.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 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

Refresh(WebBrowserRefreshOption)

Source:
WebBrowser.cs
Source:
WebBrowser.cs
Source:
WebBrowser.cs

Reloads the document currently displayed in the WebBrowser control using the specified refresh options.

C#
public void Refresh(System.Windows.Forms.WebBrowserRefreshOption opt);

Parameters

Remarks

The WebBrowser control stores recently visited Web pages in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. The Refresh method forces the WebBrowser control to reload the current page. The type of reload depends on the WebBrowserRefreshOption value specified. If you call the Refresh method with the WebBrowserRefreshOption.Completely value, the latest version of the document is downloaded. If you use the WebBrowserRefreshOption.IfExpired value, the latest version is downloaded only if the current document has expired. If you use the WebBrowserRefreshOption.Normal value, the server sends a copy of the document stored in its own cache.

Note

A document refresh simply reloads the current page, so the Navigating, Navigated, and DocumentCompleted events do not occur when you call the Refresh method.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 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