From 2c81d09d0eac1364fa6a9c1eca65a1a54acc60ec Mon Sep 17 00:00:00 2001 From: Elitsa Marinovska Date: Wed, 13 Jan 2021 10:59:27 +0100 Subject: [PATCH] Replacing HttpResponseException in Attributes --- .../Filters/DataTypeValidateAttribute.cs | 5 ++--- .../Filters/UserGroupValidateAttribute.cs | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.BackOffice/Filters/DataTypeValidateAttribute.cs b/src/Umbraco.Web.BackOffice/Filters/DataTypeValidateAttribute.cs index b67cd17afc..26c3b419ba 100644 --- a/src/Umbraco.Web.BackOffice/Filters/DataTypeValidateAttribute.cs +++ b/src/Umbraco.Web.BackOffice/Filters/DataTypeValidateAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Net; using Microsoft.AspNetCore.Mvc; @@ -10,7 +10,6 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Core.Services; using Umbraco.Extensions; using Umbraco.Web.Common.ActionsResults; -using Umbraco.Web.Common.Exceptions; using Umbraco.Web.Models.ContentEditing; namespace Umbraco.Web.BackOffice.Filters @@ -106,7 +105,7 @@ namespace Umbraco.Web.BackOffice.Filters if (context.ModelState.IsValid == false) { // if it is not valid, do not continue and return the model state - throw HttpResponseException.CreateValidationErrorResponse(context.ModelState); + context.Result = new ValidationErrorResult(context.ModelState); } } } diff --git a/src/Umbraco.Web.BackOffice/Filters/UserGroupValidateAttribute.cs b/src/Umbraco.Web.BackOffice/Filters/UserGroupValidateAttribute.cs index 8c6e85a44c..f6647ea1d7 100644 --- a/src/Umbraco.Web.BackOffice/Filters/UserGroupValidateAttribute.cs +++ b/src/Umbraco.Web.BackOffice/Filters/UserGroupValidateAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Net; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; @@ -7,7 +7,7 @@ using Umbraco.Core.Mapping; using Umbraco.Core.Models.Membership; using Umbraco.Core.Services; using Umbraco.Web.BackOffice.ActionResults; -using Umbraco.Web.Common.Exceptions; +using Umbraco.Web.Common.ActionsResults; using Umbraco.Web.Models.ContentEditing; namespace Umbraco.Web.BackOffice.Filters @@ -86,7 +86,7 @@ namespace Umbraco.Web.BackOffice.Filters if (context.ModelState.IsValid == false) { //if it is not valid, do not continue and return the model state - throw HttpResponseException.CreateValidationErrorResponse(context.ModelState); + context.Result = new ValidationErrorResult(context.ModelState); } }