0

I am using captchaMVC and on IsCaptchaValid("") I am getting A potentially dangerous Request.Form value was detected from the client error. That's because lname field has html content lname="<p>Test</p>" How can I fix this error

            [ValidateInput(false)]   
            [HttpPost]
            public ActionResult Index(FormCollection dataColl)
            {
                Test datgrp = new Test();
                datgrp.fname = dataColl[0].ToString();
                datgrp.lname = dataColl[1].ToString();

                if (!this.IsCaptchaValid(""))*****//ERROR IS HERE*****
                {

                    ViewBag.Classname = "alert alert-warning";
                    ViewBag.ErrorMessage = "Incorrect captcha answer.";
                }
                else
                {
                    ViewBag.ErrorMessage = "OKAY";
                    return RedirectToAction("Index", "Home");
                }

                return View(datgrp);
            }
sgl
  • 563
  • 1
  • 6
  • 16
  • https://stackoverflow.com/questions/81991/a-potentially-dangerous-request-form-value-was-detected-from-the-client – DanB Sep 20 '18 at 18:56
  • Can you show view code to clarify why you can insert HTML tags to `lname` (which normally should be disallowed)? If you really want to allow HTML tags, also put `[AllowHtml]` attribute to `lname` property. – Tetsuya Yamamoto Sep 21 '18 at 03:25

0 Answers0