This documentation is archived and is not being maintained.

FileWebResponse.ResponseUri Property

Gets the URI of the file system resource that provided the response.

[Visual Basic]
Overrides Public ReadOnly Property ResponseUri As Uri
[C#]
public override Uri ResponseUri {get;}
[C++]
public: __property Uri* get_ResponseUri();
[JScript]
public override function get ResponseUri() : Uri;

Property Value

A Uri that contains the URI of the file system resource that provided the response.

Remarks

The ResponseUri property contains the URI of the file system resource that provided the response. This is always the file system resource that was requested.

Example

[Visual Basic, C#, C++] The following example uses the ResponseUri to retrieve the URI of the file system resource that provided the response.

[Visual Basic] 
Public Shared Sub GetPage(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

[C#] 
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);
         }
}

[C++] 
void GetPage(String* url) {
   try {
      Uri* fileUrl = new Uri(String::Concat(S"file://", url));
      // Create a 'FileWebrequest' object with the specified Uri .
      FileWebRequest* myFileWebRequest =
         dynamic_cast<FileWebRequest*>(WebRequest::Create(fileUrl));
      // Send the 'fileWebRequest' and wait for response.
      FileWebResponse* myFileWebResponse =
         dynamic_cast<FileWebResponse*>(myFileWebRequest->GetResponse());
      Console::WriteLine(S"\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(S"\r\nWebException thrown.The Reason for failure is : {0}",
         __box(e->Status));
   } catch (Exception* e) {
      Console::WriteLine(S"\nThe following Exception was raised : {0}",
         e->Message);
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

FileWebResponse Class | FileWebResponse Members | System.Net Namespace

Show: