Thursday, 6 December 2012

Captcha not working when hosted in IIS

Problem:

Recently I faced a problem that captcha was working when I browse my page which contains Captcha , was working fine, but when I hosted site in IIS , captcha image was not appearing instead it was showing just cross mark when I browse page in IE.

Solution:

Finally I found its solution. If you check the path of captcha image by right click, take properties of the image which is appearing as red cross mark, it will show you what its actually trying to hit or show, in my case it was an aspx patch with name CaptchaImage.aspx?id={xxxxx}, something like this.

So what I did, in IIS, 
1. selected my application, and
2. then chose "Handler Mappings", 
3. then clicked "Add Managed Handler" under "Action",

4. Request Path : Type the target url path of your captcha, as in my case mentioned above as page CaptchaImage.aspx,
in some cases it could be with different extension like CaptchaImage.axd, to confirm this, check your web.config , you will find this path in the tag you added for captch to work.
5. Type :  choose your dll or assembly from dropdown, if it is  not appearing , then you will have to add that assembly or dll as reference in your application or project from VS.
6. Name:  Type  any name for the hanlder, like CaptchaHandlerMapping . and click OK.




Now again browse page having captcha , it must work!!.
Hope this help.


No comments:

Post a Comment