This repository was archived by the owner on Dec 14, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
src/Microsoft.AspNet.Mvc.Core/ActionResults Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments