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

System.Net.WebRequest Extension Methods

WebRequest.GetResponseSafe Method

A WebRequest extension method that gets the WebRequest response or the WebException response.

Syntax

WebResponse GetResponseSafe(WebRequest @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_WebRequest_GetResponseSafe
     {
         [TestMethod]
         public void GetResponseSafe()
         {
             // Type
             WebRequest @this = WebRequest.Create("http://www.zzzportal.com/");
 
             // Examples
             WebResponse value = @this.GetResponseSafe(); // return a response;
 
             // Unit Test
             Assert.IsNotNull(value);
         }
     }
 }
                

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