Bagikan melalui


FileWebResponse.ResponseUri Properti

Definisi

Mendapatkan URI sumber daya sistem file yang memberikan respons.

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

Nilai Properti

Uri

Uri yang berisi URI sumber daya sistem file yang memberikan respons.

Contoh

Contoh berikut menggunakan ResponseUri untuk mengambil URI sumber daya sistem file yang memberikan respons.

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

Keterangan

Properti ResponseUri berisi URI sumber daya sistem file yang memberikan respons. Ini selalu merupakan sumber daya sistem file yang diminta.

Berlaku untuk