Tuesday, 15 May 2012

c# - MS Captcha timeout duration in registration form in ASP.Net -


I am currently using an MS Captcha in the registration form. It works perfectly if the form is stored within a minute. But sometimes, after filling the form, the user then searches for documents to upload, and finally when they submit the form, they get a server error below:

[ NullReferenceException: The object reference is not set. On an example of the object] MSCaptcha.CaptchaControl.ValidateCaptcha (string userEntry) 438

button to submit, I call ValidateCaptcha as below:

  Captcha 1 Validity Captcha (txtCaptcha.Text.Trim ()); Can anyone help me handle this exception? thank you in advanced.   

It has been observed that throws address you have not set ErrorInputTooFast and ErrorInputTooSlow messages that 'NullReferenceException' When the CaptchaMaxTimeout time period has passed.

I have set the following properties to be able to work without NullReferenceException as well as

ErrorInputTooFast = "Image text was typed too quickly." ErrorInputTooSlow = "Image text was typed so slow."

My implementation is as below and if I continue to have this problem, then set CaptchaMaxTimeout as 20 seconds to see

 . & Lt; UC: CaptchaControl id = "CaptchaUserControl" runat = "server" Height = "50px" ValidationGroup = "PageValidationGroup" CustomValidatorErrorMessage = width = "180px" CaptchaLength = "5" FONTCOLOR "text did not match the image provided you enter" = "# 000000" BackColor = "# e6db55" NoiseColor = "# 26557f" CaptchaLineNoise = "none" CaptchaFontWarping = "low" ImageTag = "border = '1' 'CaptchaBackgroundNoise =" Medium "ErrorInputTooFast =" image text very quickly Was typed. The "ErrorInputTooSlow =" image text was typed very slowly. "CAPTCHAxTimeet =" 20 "CAPTCHA MINUTIMET =" 2 "enabledVeget =" False "/>    

Back code

  Private Zero AppendValidationErrorMessage (string message) {var cv = new CustomValidator (); Cv. IsValid = false; Cv.ErrorMessage = Message; Cv.ValidationGroup = "PageValidationGroup"; this.Page.Validators.Add (CV);} Protected Zero SubmitButtonClick (Object Sender, EventArgs e) {try {this.CaptchaUserControl .validateCaptcha (CapthaTextBox.Text.GetTrimValue ()); if {this.AppendValidationErrorMessage (this.CaptchaUserControl.CustomValidatorErrorMessage) (this.CaptchaUserControl.UserValidated!);}} Grip (Exception) {this.AppendValidationErrorMessage ("Captcha has expired Please copy the data before page.Note reload data refresh please ");} This.CapthaTextBox.Text = string.Empty; if (this.Page.IsValid) // and amp; This.CaptchaUserControl.UserValidated {// some}}    

No comments:

Post a Comment