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

Captcha Image Fails to Render on a load balanced

1 Answer 64 Views
Captcha
This is a migrated thread and some comments may be shown as answers.
Aslam
Top achievements
Rank 1
Aslam asked on 16 Aug 2012, 01:37 PM
Hi,

I read that in a load balancing network, the session needs to be out of process
http://www.telerik.com/help/aspnet-ajax/captcha-webfarm-and-webgarden.html

I have a project converting objects to serialize will be a big job.

Is there any other alternative to make this work.
I mean any solution that uses "Inproc" session to work with load balancing

regards
Aslam

1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 21 Aug 2012, 08:26 AM
Hi Aslam,

You can use the following approach - storing the CaptchaImage object in a custom storage medium (for example database), and serving the image via custom HttpHandler. These steps describe the suggested solution:

  1. In the Page.Init event the text code from the CaptchaImage (CaptchaImage.Text) stored in the DB or Session (if any CaptchaImage) is retrieved.
  2. In the Page.Init event an ASP.NET Image control is created, and the ImageUrl is set to the path of the HttpHandler that serves the CaptchaImage. The Image is added to the Page.
  3. A custom HttpHandler (CustomNameSpace.CaptchaImageHandler in my case) that will serve the image is created.
  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 yellow) can be any path chosen by you.
  6. On a button click the text entered in a TextBox is compared to the one of the CaptchaImage and a respective message is displayed.

I have attached a sample that implements this approach so that you can check it in action and use it as a reference for your further development.


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
Aslam
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or