如何在ASP.NET MVC中使用带PostBack的服务器控件?

Gab*_*elC 2 asp.net-mvc postback servercontrols

单击该按钮后,它会抛出"viewstate MAC failed的验证"异常.我知道MVC不支持PostBack但是有什么方法可以解决这个问题吗?

或者我们需要在MVC中使用HtmlHelper?

以下是我在View中的代码:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<form id="form1" runat="server">

<h2>Hello World</h2>

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<br />

<asp:Button ID="Button1" runat="server" Text="Button" />

</form>

</asp:Content>
Run Code Online (Sandbox Code Playgroud)

And*_*are 7

不要对抗你的框架 - 如果你想使用ASP.NET MVC,那么继续使用它,但是使用框架的工具创建控件.

如果您想要或需要使用回发控件,那么您真的应该坚持使用常规的旧ASP.NET.