Andre Lombaard
Andre Lombaard

Reputation: 7105

Razor form displaying unwanted text on page

I have an page where I create a form like

@{
    ViewBag.Title = "Login";
}

@Styles.Render("~/bundles/login/css")

@Html.BeginForm("Index", "Login", null)
{
    // Normal HTML content that constructs the form.
}

The form works as expected and is redirecting to the specified controller when submitted, but the following unwanted text is displayed at the top of the page,

System.Web.Mvc.Html.MvcForm {}

I can't figure out why this text would be displayed. Any ideas?

Upvotes: 1

Views: 126

Answers (2)

Farax
Farax

Reputation: 1477

You should use

@using(Html.BeginForm("Index", "Login", null))
{
//Code here 
}

or Else use

Html.EndForm for complimenting the Html.Beginform

Upvotes: 2

Soner Sevinc
Soner Sevinc

Reputation: 400

@{
ViewBag.Title = "Login";
}

@Styles.Render("~/bundles/login/css")

@using(Html.BeginForm("Index", "Login", null))
{
 // Normal HTML content that constructs the form.
}

Upvotes: 2

Related Questions