diff --git a/src/Microsoft.AspNet.Mvc.Core/HttpOkObjectResult.cs b/src/Microsoft.AspNet.Mvc.Core/HttpOkObjectResult.cs
new file mode 100644
index 0000000000..5efefa2173
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.Core/HttpOkObjectResult.cs
@@ -0,0 +1,24 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using Microsoft.AspNet.Http;
+
+namespace Microsoft.AspNet.Mvc
+{
+ ///
+ /// An that when executed performs content negotiation, formats the entity body, and
+ /// will produce a response if negotiation and formatting succeed.
+ ///
+ public class HttpOkObjectResult : ObjectResult
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The content to format into the entity body.
+ public HttpOkObjectResult(object value)
+ : base(value)
+ {
+ StatusCode = StatusCodes.Status200OK;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Core/HttpOkResult.cs b/src/Microsoft.AspNet.Mvc.Core/HttpOkResult.cs
new file mode 100644
index 0000000000..51482ca450
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.Core/HttpOkResult.cs
@@ -0,0 +1,22 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using Microsoft.AspNet.Http;
+
+namespace Microsoft.AspNet.Mvc
+{
+ ///
+ /// An that when executed will produce an empty
+ /// response.
+ ///
+ public class HttpOkResult : HttpStatusCodeResult
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public HttpOkResult()
+ : base(StatusCodes.Status200OK)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs
index c34773f95a..50c15a411d 100644
--- a/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs
+++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs
@@ -463,6 +463,33 @@ namespace Microsoft.AspNet.Mvc
return new JsonResult(data, serializerSettings);
}
+ ///
+ /// Creates a object that produces an empty OK (200) response.
+ ///
+ /// The created for the response.
+ [NonAction]
+ public virtual HttpOkResult Ok()
+ {
+ return new HttpOkResult();
+ }
+
+ ///
+ /// Creates an object that produces an OK (200) response.
+ ///
+ /// The content value to format in the entity body.
+ /// The created for the response.
+ [NonAction]
+ public virtual HttpOkObjectResult Ok(object value)
+ {
+ var disposableValue = value as IDisposable;
+ if (disposableValue != null)
+ {
+ Response.RegisterForDispose(disposableValue);
+ }
+
+ return new HttpOkObjectResult(value);
+ }
+
///
/// Creates a object that redirects to the specified .
///
@@ -1025,7 +1052,7 @@ namespace Microsoft.AspNet.Mvc
///
/// The type of the model object.
/// The model instance to update.
- /// A that on completion returns true if the update is successful
+ /// A that on completion returns true if the update is successful.
[NonAction]
public virtual Task TryUpdateModelAsync([NotNull] TModel model)
where TModel : class
@@ -1039,9 +1066,9 @@ namespace Microsoft.AspNet.Mvc
///
/// The type of the model object.
/// The model instance to update.
- /// The prefix to use when looking up values in the current
+ /// The prefix to use when looking up values in the current .
///
- /// A that on completion returns true if the update is successful
+ /// A that on completion returns true if the update is successful.
[NonAction]
public virtual async Task TryUpdateModelAsync([NotNull] TModel model,
[NotNull] string prefix)
@@ -1067,7 +1094,7 @@ namespace Microsoft.AspNet.Mvc
/// The prefix to use when looking up values in the .
///
/// The used for looking up values.
- /// A that on completion returns true if the update is successful
+ /// A that on completion returns true if the update is successful.
[NonAction]
public virtual async Task TryUpdateModelAsync([NotNull] TModel model,
[NotNull] string prefix,
@@ -1105,7 +1132,7 @@ namespace Microsoft.AspNet.Mvc
///
/// (s) which represent top-level properties
/// which need to be included for the current model.
- /// A that on completion returns true if the update is successful
+ /// A that on completion returns true if the update is successful.
[NonAction]
public async Task TryUpdateModelAsync(
[NotNull] TModel model,
@@ -1144,7 +1171,7 @@ namespace Microsoft.AspNet.Mvc
/// The prefix to use when looking up values in the current .
///
/// A predicate which can be used to filter properties at runtime.
- /// A that on completion returns true if the update is successful
+ /// A that on completion returns true if the update is successful.
[NonAction]
public async Task TryUpdateModelAsync(
[NotNull] TModel model,
@@ -1180,12 +1207,12 @@ namespace Microsoft.AspNet.Mvc
///
/// The type of the model object.
/// The model instance to update.
- /// The prefix to use when looking up values in the
+ /// The prefix to use when looking up values in the .
///
/// The used for looking up values.
/// (s) which represent top-level properties
/// which need to be included for the current model.
- /// A that on completion returns true if the update is successful
+ /// A that on completion returns true if the update is successful.
[NonAction]
public async Task TryUpdateModelAsync(
[NotNull] TModel model,
@@ -1222,11 +1249,11 @@ namespace Microsoft.AspNet.Mvc
///
/// The type of the model object.
/// The model instance to update.
- /// The prefix to use when looking up values in the
+ /// The prefix to use when looking up values in the .
///
/// The used for looking up values.
/// A predicate which can be used to filter properties at runtime.
- /// A that on completion returns true if the update is successful
+ /// A that on completion returns true if the update is successful.
[NonAction]
public async Task TryUpdateModelAsync(
[NotNull] TModel model,
@@ -1263,9 +1290,9 @@ namespace Microsoft.AspNet.Mvc
///
/// The model instance to update.
/// The type of model instance to update.
- /// The prefix to use when looking up values in the current
+ /// The prefix to use when looking up values in the current .
///
- /// A that on completion returns true if the update is successful
+ /// A that on completion returns true if the update is successful.
[NonAction]
public virtual async Task TryUpdateModelAsync([NotNull] object model,
[NotNull] Type modelType,
@@ -1299,11 +1326,11 @@ namespace Microsoft.AspNet.Mvc
///
/// The model instance to update.
/// The type of model instance to update.
- /// The prefix to use when looking up values in the
+ /// The prefix to use when looking up values in the .
///
/// The used for looking up values.
/// A predicate which can be used to filter properties at runtime.
- /// A that on completion returns true if the update is successful
+ /// A that on completion returns true if the update is successful.
[NonAction]
public async Task TryUpdateModelAsync(
[NotNull] object model,
@@ -1339,7 +1366,7 @@ namespace Microsoft.AspNet.Mvc
/// Validates the specified instance.
///
/// The model to validate.
- /// true if the is valid; false otherwise.
+ /// true if the is valid; false otherwise.
[NonAction]
public virtual bool TryValidateModel([NotNull] object model)
{
@@ -1352,7 +1379,7 @@ namespace Microsoft.AspNet.Mvc
/// The model to validate.
/// The key to use when looking up information in .
///
- /// true if the is valid;false otherwise.
+ /// true if the is valid;false otherwise.
[NonAction]
public virtual bool TryValidateModel([NotNull] object model, string prefix)
{
diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/OkNegotiatedContentResult.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/OkNegotiatedContentResult.cs
deleted file mode 100644
index be288e604b..0000000000
--- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/OkNegotiatedContentResult.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Net;
-using Microsoft.AspNet.Mvc;
-using Microsoft.Framework.Internal;
-
-namespace System.Web.Http
-{
- ///
- /// Represents an action result that performs content negotiation and returns an
- /// response when it succeeds.
- ///
- /// The type of content in the entity body.
- public class OkNegotiatedContentResult : NegotiatedContentResult
- {
- ///
- /// Initializes a new instance of the class with the values
- /// provided.
- ///
- /// The content value to negotiate and format in the entity body.
- public OkNegotiatedContentResult([NotNull] T content)
- : base(HttpStatusCode.OK, content)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/OkResult.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/OkResult.cs
deleted file mode 100644
index 17989ad863..0000000000
--- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/OkResult.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.AspNet.Http;
-using Microsoft.AspNet.Mvc;
-
-namespace System.Web.Http
-{
- ///
- /// An action result that returns an empty response.
- ///
- public class OkResult : HttpStatusCodeResult
- {
- ///
- /// Initializes a new instance of the class.
- ///
- public OkResult()
- : base(StatusCodes.Status200OK)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ApiController.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ApiController.cs
index 51ee047790..778f8dc1a0 100644
--- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ApiController.cs
+++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ApiController.cs
@@ -295,25 +295,25 @@ namespace System.Web.Http
}
///
- /// Creates an (200 OK).
+ /// Creates an (200 OK).
///
- /// An .
+ /// An .
[NonAction]
- public virtual OkResult Ok()
+ public virtual HttpOkResult Ok()
{
- return new OkResult();
+ return new HttpOkResult();
}
///
- /// Creates an (200 OK) with the specified values.
+ /// Creates an (200 OK) with the specified values.
///
/// The type of content in the entity body.
/// The content value to negotiate and format in the entity body.
- /// An with the specified values.
+ /// An with the specified values.
[NonAction]
- public virtual OkNegotiatedContentResult Ok([NotNull] T content)
+ public virtual HttpOkObjectResult Ok(T content)
{
- return new OkNegotiatedContentResult(content);
+ return new HttpOkObjectResult(content);
}
///
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/HttpOkObjectResultTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/HttpOkObjectResultTest.cs
new file mode 100644
index 0000000000..ec1f3b7d36
--- /dev/null
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/HttpOkObjectResultTest.cs
@@ -0,0 +1,99 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Threading.Tasks;
+using Microsoft.AspNet.Http;
+using Microsoft.AspNet.Http.Internal;
+using Microsoft.AspNet.Routing;
+using Microsoft.Framework.DependencyInjection;
+using Microsoft.Framework.Logging;
+using Microsoft.Framework.Logging.Testing;
+using Microsoft.Framework.OptionsModel;
+using Xunit;
+
+namespace Microsoft.AspNet.Mvc
+{
+ public class HttpOkObjectResultTest
+ {
+ public static TheoryData