protected void CustomChallengeResponse(object sender, NoBotEventArgs e) { // This is a sample challenge/response implementation that involves // the DOM so as to make the calculation more difficult to thwart. // It adds a randomly sized Panel; the client must calculate the area. Panel p = new Panel(); p.ID = "NoBotSamplePanel"; Random rand = new Random(); p.Width = rand.Next(300); p.Height = rand.Next(200); p.Style.Add(HtmlTextWriterStyle.Visibility, "hidden"); p.Style.Add(HtmlTextWriterStyle.Position, "absolute"); ((NoBot)sender).Controls.Add(p); e.ChallengeScript = string.Format("var e = document.getElementById('{0}'); e.offsetWidth * e.offsetHeight;", p.ClientID); e.RequiredResponse = (p.Width.Value * p.Height.Value).ToString(); }
protected void NoBot2_GenerateChallengeAndResponse(object sender, NoBotEventArgs e) { // A simple challenge e.ChallengeScript = "'cHaLlEnGe'.toUpperCase()"; e.RequiredResponse = "CHALLENGE"; }