Removed custom object result accepting status code as out of box ObjectResult provides this already.
This commit is contained in:
parent
514460b801
commit
49294b7d28
|
|
@ -1,25 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace FormatterWebSite
|
||||
{
|
||||
public class CustomObjectResult : ObjectResult
|
||||
{
|
||||
public CustomObjectResult(object value, int statusCode) : base(value)
|
||||
{
|
||||
StatusCode = statusCode;
|
||||
}
|
||||
|
||||
public int StatusCode { get; private set; }
|
||||
|
||||
public override Task ExecuteResultAsync(ActionContext context)
|
||||
{
|
||||
context.HttpContext.Response.StatusCode = StatusCode;
|
||||
|
||||
return base.ExecuteResultAsync(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ namespace FormatterWebSite
|
|||
{
|
||||
if (!context.ModelState.IsValid)
|
||||
{
|
||||
context.Result = new CustomObjectResult(context.ModelState, 400);
|
||||
context.Result = new ObjectResult(context.ModelState) { StatusCode = 400 };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue