Freigeben über


Uri

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the Uniform Resource Identifier (URI) of the download request.

value = downloaderObject.Uri

Property Value

Type: string

A string value that corresponds to the URI of the Downloader object request.

This property is read-only. The default value is an empty string.

Managed Equivalent

None. Downloader does not exist in the managed API. Generally you can use WebClient for downloads, which provides equivalent functionality.

Remarks

When you invoke the Open method of the Downloader object, you specify a uri parameter that represents the data to be downloaded. The Uri property corresponds to the value of the uri parameter of the Open method. The Uri property provides a way to differentiate downloaded content if you use shared DownloadProgressChanged or Completed event handler functions for multiple Downloader object requests.

NoteNote:

The Uri value must reference a file that comes from the same site of origin as the instantiated Silverlight plug-in. Usually, this is accomplished by specifying a relative URI.

Example

The following JavaScript example shows how to use the Uri property in a Completed event handler function to determine what actions to take for the returned value of the GetResponseText method invocations. Because the downloaded content does not represent packaged content, the part parameter for GetResponseText must be set to an empty string.

// Event handler for the Completed event.
function onCompleted(sender, eventArgs)
{
    // If HTTP status code indicates "OK", determine action based on URI property.
    if (sender.uri == "OK_button.js")
    {
        // Evaluate JavaScript code -- causes code to be memory-resident.
        eval(sender.ResponseText);
    }

    if (sender.uri == "OK_button.xaml")
    {
        // Retrieve downloaded XAML content.
        var xamlFragment = sender.ResponseText;

        // Create the objects from the XAML content.
        var plugin = sender.getHost();
        var button = plugin.content.createFromXaml(xamlFragment);

        // Add downloaded XAML content to the root Canvas of the plug-in.
        var rootCanvas = sender.findName("rootCanvas");
        rootCanvas.children.add(button);
    }
}

Applies To

Downloader