This project has moved. For the latest updates, please go here.

System.Web.HttpResponse Extension Methods

HttpResponse.SetFileNotFound Method

A HttpResponse extension method that sets the response to status code 404 (Not Found).

Syntax

void SetFileNotFound(HttpResponse @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.IO;
 using System.Web;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_Web_HttpResponse_SetFileNotFound
     {
         [TestMethod]
         public void SetFileNotFound()
         {
             var writer = new StringWriter();
 
             // Type
             var @this = new HttpResponse(writer);
 
             // Examples
             @this.SetFileNotFound(); // return response as file not found.
 
             // Unit Test
             Assert.AreEqual(404, @this.StatusCode);
         }
     }
 }
                

HttpResponse.SetInternalServerError Method

A HttpResponse extension method that sets the response to status code 500 (Internal Server Error).

Syntax

void SetInternalServerError(HttpResponse @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.IO;
 using System.Web;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_Web_HttpResponse_SetInternalServerError
     {
         [TestMethod]
         public void SetInternalServerError()
         {
             var writer = new StringWriter();
 
             // Type
             var @this = new HttpResponse(writer);
 
             // Examples
             @this.SetInternalServerError(); // return response as internal server error.
 
             // Unit Test
             Assert.AreEqual(500, @this.StatusCode);
         }
     }
 }
                

Last edited Nov 23, 2013 at 6:57 PM by Jonathan_Magnan, version 1