Thursday, July 10, 2014

A potentially dangerous Request.Form value was detected from the client

The runtime throws an error if you try and enter script or HTML like content in the form.
Turning off validation can be done by applying the ValidateInput attribute to the top of the Action Method with false as the boolean parameter as shown below:
        [HttpPost]
        [ValidateInput(false)]
        public ActionResult Create(Packages packages)
        {
            try
            {
                // TODO: Add insert logic here             
                      InsertPackage(packages);

                return RedirectToAction("Index");
            }
            catch(Exception ex)
            {
                return View();
            }
        }
Not too hard… It is up to you to know what you are doing after this of course!

No comments :

Post a Comment