This is a migrated thread and some comments may be shown as answers.

Error in telerik demo at http://demos.telerik.com/aspnet-ajax/captcha/examples/localization/defaultcs.aspx

3 Answers 77 Views
Captcha
This is a migrated thread and some comments may be shown as answers.
Rodrigo
Top achievements
Rank 1
Rodrigo asked on 06 Feb 2015, 05:53 PM
I have created an ASP.NET Web Application project in Visual Studio 2010 based on the telerik demo at http://demos.telerik.com/aspnet-ajax/captcha/examples/localization/defaultcs.aspx
The error can be easily reproduced.  I run the app locally and VS launches IE with a localhost web page.  Don't enter any code in this page at this moment.  Open another web page similar to the previous one. Now go back to the original page and enter the captcha code.  The code will be invalid.
Please, any idea why this happens?

3 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 11 Feb 2015, 09:46 AM
Hello Rodrigo,

The problem you described appears to be similar to an issue with RadCaptcha when its validation code is stored in the Cache of the application that was fixed in the Q2 2013 release of the Telerik controls (version 2013.2.611).

The issue was that when you open the page with the captcha on another browser tab or window, a new validation code is generated and the code that is displayed in the original tab/window you opened is no longer valid.

The best way to resolve this issue is to upgrade the Telerik controls to the latest version available. It is also possible to avoid the problem at hand by switching the ImageStorageLocation property of the captcha to Session. Note that in this case you also need to change the way Telerik.Web.UI.WebResource.axd handler is registered as described in the following help article: http://www.telerik.com/help/aspnet-ajax/captcha_getting_started.html

Regards,
Slav
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Rodrigo
Top achievements
Rank 1
answered on 12 Feb 2015, 05:49 PM
Thanks Slav for your help. 
The current version we have is 13.1.403.  So this explains why the issue is happening.  My company intends to upgrade Telerik controls by the end of this year but I am supposed to fix this as soon as possible. 
I have tried to set ImageStorageLocation to Session and also updated my web.config accordingly (handlers).  However, in this case I get the following error:

Server Error in '/' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.  Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error:
 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  Stack Trace:  [NullReferenceException: Object reference not set to an instance of an object.]
   Telerik.Web.UI.WebResource.Exists(HttpContext context, String path, String applicationPath) +1874
   Telerik.Web.UI.RadStyleSheetManager.OnPreRender(EventArgs e) +138
   System.Web.UI.Control.PreRenderRecursiveInternal() +103
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496 
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1022
0
Slav
Telerik team
answered on 17 Feb 2015, 01:02 PM
Hello Rodrigo,

I already responded to the support ticket on the matter. I will post the response here as well so that anyone who encounters the same scenario can check it:

It appears that the problem with reloading the validation code of RadCaptcha affected the Session storage method as well. The problem with this scenario is less likely to encounter, because it happens only when you open the page with the captcha in another tab of the same browser.

This is also fixed with the next release of UI for ASP.NET AJAX (2013.2.611), however the solution is too complex in order to send you a workaround for an earlier version of the controls.
 
I would strongly recommend upgrading to the latest version of the Telerik controls. Nevertheless, if this is not an option at the moment, there is an outdated customization that should allow you to change the logic of the clearing of captcha codes, so that the current code is not cleared when you open a new tab with the captcha.

You can find a sample that shows this customization in the following forum thread: http://www.telerik.com/forums/captcha-grey-box#mmP2Pi7rCkyUopI90LsHgg. What you could do is store a number of previous codes in a collection and when validating the input, compare it with the content of this collection in addition to the value of the current captcha code.

Regards,
Slav
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Captcha
Asked by
Rodrigo
Top achievements
Rank 1
Answers by
Slav
Telerik team
Rodrigo
Top achievements
Rank 1
Share this question
or