diff --git a/src/Umbraco.Web.BackOffice/PropertyEditors/TagsDataController.cs b/src/Umbraco.Web.BackOffice/PropertyEditors/TagsDataController.cs index 17d015abc803..7f02de479448 100644 --- a/src/Umbraco.Web.BackOffice/PropertyEditors/TagsDataController.cs +++ b/src/Umbraco.Web.BackOffice/PropertyEditors/TagsDataController.cs @@ -1,10 +1,11 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.PublishedCache; using Umbraco.Cms.Web.BackOffice.Controllers; using Umbraco.Cms.Web.Common.Attributes; +using Umbraco.Cms.Web.Common.Filters; using Umbraco.Extensions; using Constants = Umbraco.Cms.Core.Constants; @@ -33,6 +34,8 @@ public TagsDataController(ITagQuery tagQuery) /// /// /// + /// + [AllowHttpJsonConfigration] public IEnumerable GetTags(string tagGroup, string culture, string query = null) { if (culture == string.Empty) culture = null; diff --git a/src/Umbraco.Web.Common/Filters/AllowHttpJsonConfigrationAttribute.cs b/src/Umbraco.Web.Common/Filters/AllowHttpJsonConfigrationAttribute.cs new file mode 100644 index 000000000000..31fddc65f107 --- /dev/null +++ b/src/Umbraco.Web.Common/Filters/AllowHttpJsonConfigrationAttribute.cs @@ -0,0 +1,42 @@ +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Serialization; +using Umbraco.Cms.Web.Common.Formatters; + +namespace Umbraco.Cms.Web.Common.Filters +{ + public class AllowHttpJsonConfigrationAttribute : TypeFilterAttribute + { + /// + /// This filter overwrites AngularJsonOnlyConfigurationAttribute and get the api back to its defualt behavior + /// + public AllowHttpJsonConfigrationAttribute() : base(typeof(AllowJsonXHRConfigrationFilter)) + { + Order = 2; // this value must be more than the AngularJsonOnlyConfigurationAttribute on order to overwrtie it + } + + private class AllowJsonXHRConfigrationFilter : IResultFilter + { + public void OnResultExecuted(ResultExecutedContext context) + { + } + + public void OnResultExecuting(ResultExecutingContext context) + { + if (context.Result is ObjectResult objectResult) + { + objectResult.Formatters.RemoveType(); + } + } + } + } +}