diff --git a/src/Microsoft.AspNetCore.Mvc.TagHelpers/RenderAtEndOfFormTagHelper.cs b/src/Microsoft.AspNetCore.Mvc.TagHelpers/RenderAtEndOfFormTagHelper.cs index 3d2f31e245..92870e8320 100644 --- a/src/Microsoft.AspNetCore.Mvc.TagHelpers/RenderAtEndOfFormTagHelper.cs +++ b/src/Microsoft.AspNetCore.Mvc.TagHelpers/RenderAtEndOfFormTagHelper.cs @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers } // Reset the FormContext - ViewContext.FormContext = null; + ViewContext.FormContext = new FormContext(); } } } diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Rendering/MvcForm.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Rendering/MvcForm.cs index f70ca6b0eb..9e6b2fbfd1 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Rendering/MvcForm.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Rendering/MvcForm.cs @@ -4,6 +4,7 @@ using System; using System.Text.Encodings.Web; using Microsoft.AspNetCore.Html; +using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Mvc.Rendering @@ -56,7 +57,7 @@ namespace Microsoft.AspNetCore.Mvc.Rendering { RenderEndOfFormContent(); _viewContext.Writer.Write(""); - _viewContext.FormContext = null; + _viewContext.FormContext = new FormContext(); } private void RenderEndOfFormContent() diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Rendering/ViewContext.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Rendering/ViewContext.cs index 76ca759c42..8e7c0e49f3 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Rendering/ViewContext.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Rendering/ViewContext.cs @@ -15,9 +15,6 @@ namespace Microsoft.AspNetCore.Mvc.Rendering /// public class ViewContext : ActionContext { - // We need a default FormContext if the user uses HTML