diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Formatters/OutputFormatterCanWriteContext.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Formatters/OutputFormatterCanWriteContext.cs
index 9d8a68c7ce..979dd749aa 100644
--- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Formatters/OutputFormatterCanWriteContext.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Formatters/OutputFormatterCanWriteContext.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Mvc.Formatters
@@ -11,6 +12,39 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
///
public abstract class OutputFormatterCanWriteContext
{
+ ///
+ ///
+ /// This constructor is obsolete and will be removed in a future version.
+ /// Please use instead.
+ ///
+ ///
+ /// Creates a new .
+ ///
+ ///
+ [Obsolete("This constructor is obsolete and will be removed in a future version. Please use the constructor taking a HttpContext instead.")]
+ protected OutputFormatterCanWriteContext()
+ {
+ }
+
+ ///
+ /// Creates a new .
+ ///
+ /// The for the current request.
+ protected OutputFormatterCanWriteContext(HttpContext httpContext)
+ {
+ if (httpContext == null)
+ {
+ throw new ArgumentNullException(nameof(httpContext));
+ }
+
+ HttpContext = httpContext;
+ }
+
+ ///
+ /// Gets or sets the context associated with the current operation.
+ ///
+ public virtual HttpContext HttpContext { get; protected set; }
+
///
/// Gets or sets the content type to write to the response.
///
diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Formatters/OutputFormatterWriteContext.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Formatters/OutputFormatterWriteContext.cs
index 78be50e68c..d9cb6cf168 100644
--- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Formatters/OutputFormatterWriteContext.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Formatters/OutputFormatterWriteContext.cs
@@ -21,28 +21,18 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
/// The of the object to write to the response.
/// The object to write to the response.
public OutputFormatterWriteContext(HttpContext httpContext, Func writerFactory, Type objectType, object @object)
+ : base(httpContext)
{
- if (httpContext == null)
- {
- throw new ArgumentNullException(nameof(httpContext));
- }
-
if (writerFactory == null)
{
throw new ArgumentNullException(nameof(writerFactory));
}
- HttpContext = httpContext;
WriterFactory = writerFactory;
ObjectType = objectType;
Object = @object;
}
- ///
- /// Gets or sets the context associated with the current operation.
- ///
- public virtual HttpContext HttpContext { get; protected set; }
-
///
/// Gets or sets a delegate used to create a for writing the response.
///