如何在ASP.NET MVC3中抑制初始验证错误

时间:2013-05-04 11:01:06

标签: asp.net-mvc asp.net-mvc-3

如果调用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");
         }
       }
       }

0 个答案:

没有答案