diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs index 4ca6389f54..ace64731b4 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs @@ -508,6 +508,17 @@ namespace Microsoft.AspNet.Mvc return result; } + + /// + /// Creates a object that produces an empty No Content (204) response. + /// + /// The created object for the response. + [NonAction] + public virtual NoContentResult NoContent() + { + return new NoContentResult(); + } + /// /// Creates a object that serializes the specified object /// to JSON. diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ControllerTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ControllerTest.cs index f509bf50ec..79d43f9168 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ControllerTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ControllerTest.cs @@ -1055,6 +1055,19 @@ namespace Microsoft.AspNet.Mvc.Test Assert.Same(model, actualViewResult.ViewData.Model); } + [Fact] + public void Controller_NoContent() + { + // Arrange + var controller = new TestableController(); + + // Act + var result = controller.NoContent(); + + // Assert + Assert.Equal(StatusCodes.Status204NoContent, result.StatusCode); + } + [Fact] public void Controller_Content_WithParameterContentString_SetsResultContent() {