【问题标题】:How to use Server Controls with PostBack with ASP.NET MVC?如何使用带有 ASP.NET MVC 的 PostBack 的服务器控件?
【发布时间】:2010-11-19 07:01:43
【问题描述】:

单击按钮后,它会引发“视图状态 MAC 验证失败”异常。我知道 MVC 不支持 PostBack,但有什么办法可以解决这个问题?

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

下面是我在视图中的代码:

<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>

【问题讨论】:

    标签: asp.net-mvc postback servercontrols


    【解决方案1】:

    不要与你的框架对抗——如果你想使用 ASP.NET MVC,那么继续使用它,但 create controls using the tools of the framework

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

    【讨论】:

      【解决方案2】:
      猜你喜欢
      • 2021-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-12
      • 1970-01-01
      相关资源
      最近更新 更多