Compartir a través de


FileWebResponse.ResponseUri Propiedad

Definición

Obtiene el identificador URI del recurso del sistema de archivos que proporcionó la respuesta.

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

Valor de propiedad

Uri

Uri que contiene el identificador URI del recurso del sistema de archivos que proporcionó la respuesta.

Ejemplos

En el ResponseUri ejemplo siguiente se usa para recuperar el URI del recurso del sistema de archivos que proporcionó la respuesta.

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

Comentarios

La ResponseUri propiedad contiene el URI del recurso del sistema de archivos que proporcionó la respuesta. Este es siempre el recurso del sistema de archivos que se solicitó.

Se aplica a