This project has moved and is read-only. For the latest updates, please go here.

System.Net.WebResponse Extension Methods

WebResponse.ReadToEnd Method

A WebResponse extension method that reads the response stream to the end.

Syntax

string ReadToEnd(WebResponse @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System.Net;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_Net_WebResponse_ReadToEnd
     {
         [TestMethod]
         public void ReadToEnd()
         {
             WebRequest webRequest = WebRequest.Create("http://www.zzzportal.com/");
 
             // Type
             WebResponse @this = webRequest.GetResponseSafe();
 
             // Examples
             string value = null;
             using (@this)
             {
                 value = @this.ReadToEnd();
             }
 
             // Unit Test
             Assert.IsNotNull(value);
         }
     }
 }
                

WebResponse.ReadToEndAndDispose Method

A WebRequest extension method that gets the WebRequest response and read the response stream.

Syntax

string ReadToEndAndDispose(WebResponse @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System.Net;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_Net_WebResponse_ReadToEndAndDispose
     {
         [TestMethod]
         public void ReadToEndAndDispose()
         {
             WebRequest webRequest = WebRequest.Create("http://www.zzzportal.com/");
 
             // Type
             WebResponse @this = webRequest.GetResponseSafe();
 
             // Examples
             string value = @this.ReadToEndAndDispose();
 
             // Unit Test
             Assert.IsNotNull(value);
         }
     }
 }
                

Last edited Nov 23, 2013 at 7:55 PM by Jonathan_Magnan, version 1