blob: f910975e3d8d1c22d7af2c244ace70d2b04fb544 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Net;
namespace System.Web.Mvc
{
public class HttpStatusCodeResult : ActionResult
{
public HttpStatusCodeResult(int statusCode)
: this(statusCode, null)
{
}
public HttpStatusCodeResult(HttpStatusCode statusCode)
: this(statusCode, null)
{
}
public HttpStatusCodeResult(HttpStatusCode statusCode, string statusDescription)
: this((int)statusCode, statusDescription)
{
}
public HttpStatusCodeResult(int statusCode, string statusDescription)
{
StatusCode = statusCode;
StatusDescription = statusDescription;
}
public int StatusCode { get; private set; }
public string StatusDescription { get; private set; }
public override void ExecuteResult(ControllerContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
context.HttpContext.Response.StatusCode = StatusCode;
if (StatusDescription != null)
{
context.HttpContext.Response.StatusDescription = StatusDescription;
}
}
}
}
|