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

Clearing previous image from Cache

10 Answers 233 Views
Captcha
This is a migrated thread and some comments may be shown as answers.
Paul Robertson
Top achievements
Rank 1
Paul Robertson asked on 10 Jan 2013, 07:04 PM
Hi there

Does anyone know if there is a way to tell radCaptcha to start from scratch and ignore any existing images in the Cache? I'm thinking that during development, when I'm hitting lots of new page loads, that previous images in the cache might be causing a trouble I have with intermittent blank Captcha images.

Could anybody advise if this is a useful way forward?

Thanks

 

10 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 14 Jan 2013, 01:06 PM
Hello Paul,

There was a problem with clearing the previous RadCaptcha images from Cache or Session, when the page is reloaded without postback, as described here. This issue has been fixed, so I would suggest upgrading to the latest release of the RadControls for ASP.NET AJAX.

If this is not the problem you encountered, please provide a detailed description of your scenario with step by step instructions for reproducing the issue so that I can help you accordingly.

Kind regards,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Paul Robertson
Top achievements
Rank 1
answered on 14 Jan 2013, 02:02 PM
Hi there

I'd be interested to read the post that you link to, in case in contains any scope for a workaround. However, the Public Issue Tracker page you link to just shows a blank page, in all the browsers I have tried. I have Silverlight installed, so can I check that this link is going to the right location?

Regards
0
Paul Robertson
Top achievements
Rank 1
answered on 15 Jan 2013, 03:56 PM
Hi there

Thanks for getting back to me about this, but really I was looking for some way of working around the issue, e.g., for example, explicitly removing a Cache or Session key entry on the first load of a page, regardless of any previous postbacks - is there really no way of examining the radCaptcha specific contents of the relevant Cache item, for example, in order to include a decision whether or not to ignore it, within an IsPostback condition? There doesn't seem to be a Cache item related to the Captcha control on the first new load of the page, so I am interested to know if there is any other way of detecting the GUID conflict bug in the version of Telerik.Web.UI that I am using. I can work with a custom version of the custom control, i.e., inheriting from radCaptcha, if that is any use at all?

Thanks
0
Slav
Telerik team
answered on 17 Jan 2013, 07:41 AM
Hi Paul,

The best way to resolve your problem is to upgrade to the latest version of RadControls for ASP.NET AJAX. If this is not possible, you can use the workaround, provided in the linked forum thread in order to always clear the previous RadCaptcha images from Session/Cache.

I checked the link and it appears to be valid, nevertheless it could take some time to load the page.

Greetings,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Paul Robertson
Top achievements
Rank 1
answered on 17 Jan 2013, 08:10 PM
Hello again

The workaround seems to be just what I need, so thanks for that, but unfortunately after a few hours experimentation, I still can't get it to work:

    protected override void Render(HtmlTextWriter writer)
    {
        RemovePrevCaptchaImage();
         base.Render(writer);
    }
 
    private void RemovePrevCaptchaImage()
    {
        if (!IsPostBack)
        {
            var id = Session[RadCaptcha1.UniqueID] as string;
            if (!string.IsNullOrEmpty(id))
            {
                Session.Remove(id);
            }
        }
        Session[RadCaptcha1.UniqueID] = RadCaptcha1.CaptchaImage.UniqueId;
    }

Although:
     Session[RadCaptcha1.UniqueID] = RadCaptcha1.CaptchaImage.UniqueId;
seems to be correctly saving the key to the session, increasing the key count accordingly, when I then go on to load the page in another tab or instance, for example, the
          if (!string.IsNullOrEmpty(id))
always returns null, as though the saved key cannot be found in the session after all, upon the next attempt by the browser. I currently have a session cookie (cookieless="false") and the default server side InProc session configured in web.config. Should I expect the CaptchaImage ID to be saved in the session correctly with this combination?

Thanks if you can advise.


0
Slav
Telerik team
answered on 22 Jan 2013, 02:31 PM
Hello Paul,

The Session is shared between the browser tabs so the UniqueID of the captcha image should be available if you open the page in a new tab. Your Session configuration is a standard one and you should not have problems with storing the id.

I would suggest checking for custom code that clears the Session of your application. If you are unable you find it, you can create a clean web site that contains only a page with the captcha, apply the workaround, verify that the values in Session are stored correctly and compare it to your actual project.

Kind regards,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Paul Robertson
Top achievements
Rank 1
answered on 24 Jan 2013, 04:07 PM
Thanks for that info ...

I'm wondering if my problem does indeed concern the issue you suggest, involving the creation of a new session id for each and every tab in the browser. I am currently using the ASP.NET session cookie method of maintaining a session, and I am thinking that the way the radcaptcha control references its captchaimage might be conflicting with the use of the session cookie. Each load of the page uses a session cookie with the same name, and if the cookie is already there from a previous load cycle, is the client-side capcha component looking for a reference in this previously created cookie, and therefore becoming confused? How should I expect the racaptcha to work with the session cookie? Presumably the captcha image itself is not stored in any form in the cookie, at best would it just be a reference to a server-side object? If I examine the session cookie, what information should I expect to see saved in the session cookie by the radcaptcha component, and am I right in assuming that no changes to the captchaimage object are ever made by the client-side component, and can only be manipulated with the server-side API, even in the most recent version of Telerik.Web.UI? It doesn't seem to matter which version I use, I am still getting bank images, which makes me think that I have misunderstood the way radCaptcha uses the session - the problem occurs using only a single server, so is not a web farm issue. Would it be possible to get a brief breakdown of how the radCaptcha should interact with the session cookie? There doesn't seem to be any information about the detais of this in any of the documentation.

Thanks very much.
0
Slav
Telerik team
answered on 29 Jan 2013, 09:55 AM
Hello Paul,

The RadCaptcha is making changes to the content of the session, which is stored on the server. The session cookie is used for storing the SessionID value, which uniquely identifies the session as described in this article.

Every time the page is loaded, as a result of a postback or when a new page is opened, the captcha checks if there is a CaptchaImage stored in the Session, removes it and saves in Session the newly generated CaptchaImage. The image in Session is used when the captcha is rendered on the page. The fact that the image is missing means that there is something interfering with the logic, used by the captcha.

Also keep in mind that all of this is executed on the server. The captcha does not provide client-side validation.

In order to find the cause I will need to examine your implementation as the provided information is not enough to pinpoint the issue. I would suggest preparing and sending a simple, fully runnable project that isolates the problem so that I can inspect it locally and assist you accordingly.

Greetings,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Paul Robertson
Top achievements
Rank 1
answered on 07 Feb 2013, 04:39 PM
Thanks for this information ...

When you say this ...
"Every time the page is loaded, as a result of a postback or when a new page is opened, the captcha checks if there is a CaptchaImage stored in the Session, removes it and saves in Session the newly generated CaptchaImage. "

... could you tell me specifically where in the page life cycle this should take place, in response to which event, if possible?

Thanks

0
Slav
Telerik team
answered on 12 Feb 2013, 09:53 AM
Hi Paul,

This happens on the PreRender event of the RadCaptcha only when the page is not loaded as a response of a client postback.

There is another forum thread that you have opened, which appears to be related to this one. Let us continue our discussion in only one of the threads as the information on the case will be easier to follow.

Greetings,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Captcha
Asked by
Paul Robertson
Top achievements
Rank 1
Answers by
Slav
Telerik team
Paul Robertson
Top achievements
Rank 1
Share this question
or