Public · Protected · Private
Disabling Request Validation in MVC
Type: Public  |  Created: 2012-08-26  |  Frozen: Yes
« Previous Public Blog Next Public Blog »
Comments
  • public class MyModelclass {
        [AllowHtml]
        public string FirstName{ get; set; }
        public string LastName { get; set; }
    }
    [ValidateInput(false)]
    public class MyController : Controller {
        public ViewResult ShowName() {
            return View(new MyModelclass { firstName = "" },firstName = "" );
        }

        [HttpPost]
        public ViewResult RegisterName(MyModelclass name) {

            if (ModelState.IsValid) {
                repository.SaveName(name);
                return View("Completed", name);
            } else {
                return View();
            }
        }
    }

     

    2012-08-26 09:51
This blog is frozen. No new comments or edits allowed.