Found a malformed 'form' tag helper. Tag helpers must have a start and end tag or be self closing


So i’m getting this error on my mvc project while working on my form.
The error indicates that I haven’t closed the form tag properly.
However, as you’ll see below, I have closed it properly.

<form method="post">

  //form content below


I have added taghelpers in my ViewImports.cshtml file as you can see below.

@using ServiceWebsite
@using ServiceWebsite.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers


I was facing the same problem but I have solve it with the following :

  • Either using pure html form
  • Or inject Helper tags into the form like so
@using (Html.BeginForm("Login", "Main", FormMethod.Post))
    @if (@ViewBag.Message != null)
        <div style="border: 1px solid red">
    <div class="mb-3">
        <label class="form-label">@Html.LabelFor(UserBindingModel => UserBindingModel.UserName) </label>

Save it and it will disappear.
I used this website as a reference.

Another example of functional form:

@model UserBindingModel

    ViewBag.Title = "Login";

<form asp-action="Login">

    <div class="mb-3">
        <label asp-for="UserName" class="form-label"></label>
        <input type="text" class="form-control" asp-for="UserName">

    <div class="mb-3">
        <label asp-for="Password" class="form-label"></label>
        <input asp-for="Password" class="form-control">


Answered By – Rose Riyadh

Answer Checked By – Candace Johnson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.