Category Archives: Image Handling

How to create a simple captcha validation in asp.net

We often see captcha validation in number of sites outthere. Earlier, when I started surfing in web, I wondered how they are created. But now I have answer for that.I am presenting you before, a simple method to implement a captcha validation in your asp.net websites (PHP folks, cheer up. I am working on a similiar thing in php too.). In this method I am using System.Drawing namespace in C#. First I am going to create a generic handler which will render the captcha image.Look at the code below

And now we are going to implement the validation. Create an aspx page, add add an img tag and for the src attribute,give the path to the handler. See below.

And now it’s time for testing the validation. Code behind will look like this.

And we are done! The validation form will look like this. Download sample project Try this and let me know the feedback.Cheers

How to create an image handler to resize external images on the fly

This post is about creating an image handler to resize external images on the fly. I got code to resize images with in our server, but i was in need to resize external images in the fly. So I modified the code. Lets create a generic handler file first, named ImageHandler.ashx.

Usage:

We can do this with our internal images also by changing the GetImage() function a little bit.
Hope you like this, enjoy coding

Cheers