Friday, August 26, 2011

How to solve "A potentially dangerous Request.Form value was detected from the client" in ASP.NET MVC 3

#1: Add AllowHtml Attribute into property in the model
#2: Turn off validation on the Action:
        [HttpPost]
        [ValidateInput(false)]
        public ActionResult Index(string htmlsource)
        {
            var x = htmlsource;
            return View();
        }
http://msdn.microsoft.com/en-us/library/system.web.mvc.allowhtmlattribute(v=vs.98).aspx


Following link is about to solve same problem in ASP.NET webform
http://rayaspnet.blogspot.ca/2011/02/how-to-properly-deal-with-exception.html

How to click a button by Javascript in Webforms?

Two ways:
1. By jQuery:
$("#ClientID").trigger("click");

2. By __doPostBack function
__doPostBack('server side id name', 'Click');