Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit f874670

Browse files
committed
cr feedback
1 parent 5f7ee46 commit f874670

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Microsoft.AspNet.Mvc.Core/ActionResults/JsonResult.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ namespace Microsoft.AspNet.Mvc
1313
/// </summary>
1414
public class JsonResult : ActionResult
1515
{
16-
private static readonly MediaTypeHeaderValue[] _defaultSupportedContentTypes = new MediaTypeHeaderValue[]
16+
/// <summary>
17+
/// The list of content-types used for formatting when <see cref="ContentTypes"/> is null or empty.
18+
/// </summary>
19+
public static readonly IReadOnlyList<MediaTypeHeaderValue> DefaultContentTypes = new MediaTypeHeaderValue[]
1720
{
1821
MediaTypeHeaderValue.Parse("application/json"),
1922
MediaTypeHeaderValue.Parse("text/json"),
@@ -65,7 +68,10 @@ public override async Task ExecuteResultAsync([NotNull] ActionContext context)
6568
// if the user has not already set it.
6669
if (ContentTypes == null || ContentTypes.Count == 0)
6770
{
68-
objectResult.ContentTypes = _defaultSupportedContentTypes;
71+
foreach (var contentType in DefaultContentTypes)
72+
{
73+
objectResult.ContentTypes.Add(contentType);
74+
}
6975
}
7076
else
7177
{

0 commit comments

Comments
 (0)