1 // Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. 2 3 using System.Text; 4 5 namespace System.Web.Mvc 6 { 7 public class ContentResult : ActionResult 8 { 9 public string Content { get; set; } 10 11 public Encoding ContentEncoding { get; set; } 12 13 public string ContentType { get; set; } 14 ExecuteResult(ControllerContext context)15 public override void ExecuteResult(ControllerContext context) 16 { 17 if (context == null) 18 { 19 throw new ArgumentNullException("context"); 20 } 21 22 HttpResponseBase response = context.HttpContext.Response; 23 24 if (!String.IsNullOrEmpty(ContentType)) 25 { 26 response.ContentType = ContentType; 27 } 28 if (ContentEncoding != null) 29 { 30 response.ContentEncoding = ContentEncoding; 31 } 32 if (Content != null) 33 { 34 response.Write(Content); 35 } 36 } 37 } 38 } 39