Skip to main content
 首页 » 编程设计

c#之Razor 表单在页面上显示不需要的文本

2024年02月13日17sharpest

我有一个页面,我可以在其中创建一个表单

@{ 
    ViewBag.Title = "Login"; 
} 
 
@Styles.Render("~/bundles/login/css") 
 
@Html.BeginForm("Index", "Login", null) 
{ 
    // Normal HTML content that constructs the form. 
} 

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

System.Web.Mvc.Html.MvcForm {} 

我不明白为什么会显示这段文字。有什么想法吗?

请您参考如下方法:

@{ 
ViewBag.Title = "Login"; 
} 
 
@Styles.Render("~/bundles/login/css") 
 
@using(Html.BeginForm("Index", "Login", null)) 
{ 
 // Normal HTML content that constructs the form. 
}