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

Captcha grey box

5 Answers 447 Views
Captcha
This is a migrated thread and some comments may be shown as answers.
TAD RHODES
Top achievements
Rank 1
TAD RHODES asked on 08 Jul 2011, 05:18 PM
I have a web farm.  I have setup my config and captcha to use session instead of cache.  It appears to work about 95% of the time, but every so often we get a grey box displayed.  Here are all my settings, etc.

Web.config
<httpHandlers>
      <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResourceSession" verb="*" validate="false" />
</httpHandlers>
 
<handlers>
      <add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResourceSession, Telerik.Web.UI" preCondition="integratedMode" />
</handlers>

<location path="Telerik.Web.UI.WebResource.axd">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
    <location path="Telerik.Web.UI.WebResourceSession.axd">
        <system.web>
            <authorization>
                <allow users="*" />
            </authorization>
        </system.web>
    </location>

ASPX
<asp:MultiView ID="mvCaptcha" runat="server" ActiveViewIndex="0">
      <
asp:View ID="vCaptcha" runat="server">
<asp:Panel runat="server" ID="pnlCaptcha" class="pnlCaptcha">
<div class="left" style="text-align: left;">
<telerik:RadCaptcha runat="server" ID="cptPassword" ValidationGroup="Verification"
ErrorMessage="Captcha message was incorrect" Display="None" CaptchaImage-EnableCaptchaAudio="true"
CaptchaTextBoxLabel="" CaptchaAudioLinkButtonText="" ImageStorageLocation="Session">
</telerik:RadCaptcha>
</div>
 <div class="left">
<asp:LinkButton ID="btnRefreshCaptcha" runat="server"><img class="imgRefreshCaptcha" alt="Refresh Captcha" src="./App_Themes/public/Images/imgCaptchaRefresh.png" /></asp:LinkButton></div>
</asp:Panel>
</asp:View>
<asp:View ID="vCaptchaPassed" runat="server">
You have already passed the captcha.
</asp:View>
</asp:MultiView>

When we receive the grey box, I can view the image and this is the url.
http://devoam.microcenter.com/OAM/Telerik.Web.UI.WebResource.axd?type=rca&isc=false&guid=73ed64b3-129c-4413-87e2-fd30fa20abc4
When I get a good image to show, I look at the url and they look identical except for the guid of course.  Like this:
http://devoam.microcenter.com/OAM/Telerik.Web.UI.WebResource.axd?type=rca&isc=false&guid=e10cd1d2-0d3d-4879-a925-11ad40781114

Now to make this a little more odd, when I get a grey image, if I right click on it and say view image, I can actually see the captcha image; not a grey box.

Not sure what's going on with it.  Any help would be appreciated.

Thanks,
Tad

5 Answers, 1 is accepted

Sort by
0
Accepted
Slav
Telerik team
answered on 13 Jul 2011, 09:33 AM
Hello Tad,

  You are receiving grey box, instead of RadCaptcha image, because in some cases a user is not handled by the same server that generated the image and nothing is returned. In order to ensure that the request is always sent to the right server, there is an option you can try - sticky sessions.

The RadCaptcha image is visible, when view image is selected, because a second request is sent to the server that first served the request for that session and the image is returned. Please check this short video in order to see the requests sent to the server.

After examining the code snippets you have provided, I can verify that you have properly stored the CaptchaImage in the Session, and configured your server environment to use out of process SessionState. I also noticed that in the web.config file you included location tag, which is not needed in your case, and can be safely removed:
<location path="Telerik.Web.UI.WebResourceSession.axd">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>

  

Best wishes,
Slav
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Kevin Cabritit
Top achievements
Rank 1
answered on 16 Mar 2012, 01:28 AM
I have the same issue as the OP here, except that I'm using a single server with the "web garden" functionality instead of a "web farm".

When the CAPTCHA does display, the SQL Server session storage works fine, just sometimes the page renders a grey box.

How can I solve this in a "web garden" situation?

0
Slav
Telerik team
answered on 20 Mar 2012, 10:17 AM
Hi Alex,

I would recommend checkig the help article Using RadCaptcha in a WebFarm/WebGarden Environment and verifying that you have configured the RadCaptcha properly.

If you are still having difficulties after reviewing the linked article, please provide a live URL to the page, displaying the problem, so that I can examine it locally and suggest an according solution. The setup of your web.config file will also be useful for inspecting the cause for your issue.

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
Kevin Cabritit
Top achievements
Rank 1
answered on 20 Mar 2012, 01:02 PM
I think the problem has been described in this thread already, as my setup mirrors the OP and the techniques described in the posted link.

You are receiving grey box, instead of RadCaptcha image, because in some cases a user is not handled by the same server that generated the image and nothing is returned. In order to ensure that the request is always sent to the right server, there is an option you can try - sticky sessions.

I don't believe the "web garden" has a "sticky sessions" functionality, so this is the issue. Is there a way to adapt the settings to work in a web garden?
0
Slav
Telerik team
answered on 22 Mar 2012, 04:56 PM
Hello Alex,

It appears sticky sessions cannot be implemented in a Web Garden scenario out-of-the-box. If you have ensured that the requirements for using RadCaptcha in a Web Garden Environment are met and the problem persists, I can suggest another approach.

For your convenience I implemented a custom solution that stores the CaptchaImage object in custom storage medium (in my case Session, you could use DB), and serves the image using custom HttpHandler.

The following steps explain the described implementation:

1. In the Page.Init I retrieve the text code from the CaptchaImage (CaptchaImage.Text) stored in the DB or Session (if any CaptchaImage).

2. In the Page.Init I create an ASP.NET Image control, and set the ImageUrl to the path of the HttpHandler that serves the CaptchaImage. The Image is added to the Page.

3. I create a custom HttpHandler (CustomNameSpace.CaptchaImageHandler in my case) that will serve the image. 

4. In the web.config, the following markup is added to register the handlers:
<system.web>
  
    <httpHandlers>
        <add path="MyCustom.CaptchaHandler.axd" type="CustomNameSpace.CaptchaImageHandler" verb="*" validate="false"/>
    </httpHandlers>
    <httpModules>
    </httpModules>
</system.web>
<system.webServer>
      
    <handlers>
        <remove name="MyCustom_CaptchaHandler_axd" />
        <add name="MyCustom_CaptchaHandler_axd" path="MyCustom.CaptchaHandler.axd" type="CustomNameSpace.CaptchaImageHandler" verb="*" preCondition="integratedMode"/>
    </handlers>
</system.webServer>

5. The path (highlighted in the sample) can be any path chosen by you.

6. On a button click I compare the text entered in a TextBox to the one of the CaptchaImage and display respective message.

You can find attached the sample project that implements this approach. I hope this will help you resolve the problem at hand.

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.
Tags
Captcha
Asked by
TAD RHODES
Top achievements
Rank 1
Answers by
Slav
Telerik team
Kevin Cabritit
Top achievements
Rank 1
Share this question
or