diff --git a/src/Microsoft.AspNetCore.Mvc.TagHelpers/ValidationSummaryTagHelper.cs b/src/Microsoft.AspNetCore.Mvc.TagHelpers/ValidationSummaryTagHelper.cs index 19adf4d495..ddd5117cd7 100644 --- a/src/Microsoft.AspNetCore.Mvc.TagHelpers/ValidationSummaryTagHelper.cs +++ b/src/Microsoft.AspNetCore.Mvc.TagHelpers/ValidationSummaryTagHelper.cs @@ -104,11 +104,15 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers message: null, headerTag: null, htmlAttributes: null); - if (tagBuilder != null) + if (tagBuilder == null) { - output.MergeAttributes(tagBuilder); - output.PostContent.AppendHtml(tagBuilder.InnerHtml); + // The generator determined no element was necessary. + output.SuppressOutput(); + return; } + + output.MergeAttributes(tagBuilder); + output.PostContent.AppendHtml(tagBuilder.InnerHtml); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Customer.Index.html b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Customer.Index.html index 26cbd426c8..a61f895061 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Customer.Index.html +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Customer.Index.html @@ -33,7 +33,7 @@