如果调用get请求,ASP.NET MVC3视图会显示验证错误。如果在MVC2中使用post post请求时如何显示验证错误?
查看:
<%= Html.ValidationSummary(false, "Error") %>
控制器:
namespace Store.Controllers
{
public class CheckoutController : MyApp.Controllers.ControllerBase
{
[HttpGet]
public ActionResult Address()
{
return View(new AddressViewModel());
}
[HttpPost, ValidateAntiForgeryToken]
public ActionResult Address(AddressViewModel model, string name) {
if (!ModelState.IsValid)
return View(model);
return RedirectToAction("Payment");
}
}
}