Implement MachineKey.Protect and MachineKey.Unprotect
[mono.git] / mcs / class / System.Web.Mvc / System.Web.Mvc / ContentResult.cs
1 /* ****************************************************************************\r
2  *\r
3  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4  *\r
5  * This software is subject to the Microsoft Public License (Ms-PL). \r
6  * A copy of the license can be found in the license.htm file included \r
7  * in this distribution.\r
8  *\r
9  * You must not remove this notice, or any other, from this software.\r
10  *\r
11  * ***************************************************************************/\r
12 \r
13 namespace System.Web.Mvc {\r
14     using System;\r
15     using System.Text;\r
16     using System.Web;\r
17 \r
18     public class ContentResult : ActionResult {\r
19 \r
20         public string Content {\r
21             get;\r
22             set;\r
23         }\r
24 \r
25         public Encoding ContentEncoding {\r
26             get;\r
27             set;\r
28         }\r
29 \r
30         public string ContentType {\r
31             get;\r
32             set;\r
33         }\r
34 \r
35         public override void ExecuteResult(ControllerContext context) {\r
36             if (context == null) {\r
37                 throw new ArgumentNullException("context");\r
38             }\r
39 \r
40             HttpResponseBase response = context.HttpContext.Response;\r
41 \r
42             if (!String.IsNullOrEmpty(ContentType)) {\r
43                 response.ContentType = ContentType;\r
44             }\r
45             if (ContentEncoding != null) {\r
46                 response.ContentEncoding = ContentEncoding;\r
47             }\r
48             if (Content != null) {\r
49                 response.Write(Content);\r
50             }\r
51         }\r
52     }\r
53 }\r