Condividi tramite


FileWebResponse.ResponseUri Proprietà

Definizione

Ottiene l'URI della risorsa del file system che ha fornito la risposta.

public:
 virtual property Uri ^ ResponseUri { Uri ^ get(); };
public override Uri ResponseUri { get; }
member this.ResponseUri : Uri
Public Overrides ReadOnly Property ResponseUri As Uri

Valore della proprietà

Uri

Uri che contiene l'URI della risorsa del file system che ha fornito la risposta.

Esempio

Nell'esempio seguente viene usato per ResponseUri recuperare l'URI della risorsa del file system che ha fornito la risposta.

void GetPage( String^ url )
{
   try
   {
      Uri^ fileUrl = gcnew Uri( String::Concat( "file://", url ) );
      
      // Create a 'FileWebrequest' object with the specified Uri .
      FileWebRequest^ myFileWebRequest = (FileWebRequest^)( WebRequest::Create( fileUrl ) );
      
      // Send the 'fileWebRequest' and wait for response.
      FileWebResponse^ myFileWebResponse = (FileWebResponse^)( myFileWebRequest->GetResponse() );
      Console::WriteLine( "\nThe Uri of the file system resource that provided the response is :\n {0}\n\n", myFileWebResponse->ResponseUri );
      
      // Release resources of response object.
      myFileWebResponse->Close();
   }
   catch ( WebException^ e ) 
   {
      Console::WriteLine( "\r\nWebException thrown. The Reason for failure is : {0}", e->Status );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message );
   }
}
public static void GetPage (String url)
{
    try
    {
        Uri fileUrl = new Uri ("file://" + url);

        // Create a 'FileWebrequest' object with the specified Uri .
        FileWebRequest myFileWebRequest = (FileWebRequest)WebRequest.Create (fileUrl);

        // Send the 'fileWebRequest' and wait for response.
        FileWebResponse myFileWebResponse = (FileWebResponse)myFileWebRequest.GetResponse ();

        Console.WriteLine ("\nThe Uri of the file system resource that provided the response is :\n{0}\n\n", myFileWebResponse.ResponseUri);

        // Release resources of response object.
        myFileWebResponse.Close ();
    }
    catch (WebException e)
    {
        Console.WriteLine ("\r\nWebException thrown. The Reason for failure is : {0}", e.Status);
    }
    catch (Exception e)
    {
        Console.WriteLine ("\nThe following Exception was raised : {0}", e.Message);
    }
}
Public Shared Sub GetPage(ByVal url As [String])
    Try
        Dim fileUrl As New Uri("file://" + url)
        ' Create a 'FileWebrequest' object with the specified Uri. 
        Dim myFileWebRequest As FileWebRequest = CType(WebRequest.Create(fileUrl), FileWebRequest)
        ' Send the 'fileWebRequest' and wait for response.
        Dim myFileWebResponse As FileWebResponse = CType(myFileWebRequest.GetResponse(), FileWebResponse)
        Console.WriteLine("The Uri of the file system resource that provided the response is : {0}", myFileWebResponse.ResponseUri)
        myFileWebResponse.Close()

    Catch e As WebException
        Console.WriteLine(ControlChars.Lf + ControlChars.Cr + "The Reason for failure is : {0}", e.Status)
    Catch e As Exception
        Console.WriteLine(ControlChars.Cr + "The following exception was raised : {0}", e.Message)
    End Try

Commenti

La ResponseUri proprietà contiene l'URI della risorsa del file system che ha fornito la risposta. Si tratta sempre della risorsa del file system richiesta.

Si applica a