剃刀表单在页面上显示不需要的文本

时间:2013-09-25 07:10:42

标签: c# asp.net-mvc razor html-helper

我有一个页面,我在其中创建一个像

这样的表单
@{
    ViewBag.Title = "Login";
}

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

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

表单按预期工作,并在提交时重定向到指定的控制器,但页面顶部显示以下不需要的文本,

System.Web.Mvc.Html.MvcForm {}

我无法弄清楚为什么会显示这个文字。有什么想法吗?

2 个答案:

答案 0 :(得分:2)

你应该使用

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

或其他使用

Html.EndForm赞美Html.Beginform

答案 1 :(得分:2)

@{
ViewBag.Title = "Login";
}

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

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