Apperently I had to create a new aspx page and add the code on that page.
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace x.Webpages
{
public partial class JpegImageCaptcha : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Session["CaptchaImageText"] = GenerateRandomCode();
RandomImage ci = new RandomImage(this.Session["CaptchaImageText"].ToString(), 300, 75);
this.Response.Clear();
this.Response.ContentType = "image/jpeg";
ci.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg);
ci.Dispose();
}
private string GenerateRandomCode()
{
Random r = new Random();
string s = "";
for (int j = 0; j < 5; j++)
{
int i = r.Next(3);
int ch;
switch (i)
{
case 1:
ch = r.Next(0, 9);
s = s + ch.ToString();
break;
case 2:
ch = r.Next(65, 90);
s = s + Convert.ToChar(ch).ToString();
break;
case 3:
ch = r.Next(97, 122);
s = s + Convert.ToChar(ch).ToString();
break;
default:
ch = r.Next(97, 122);
s = s + Convert.ToChar(ch).ToString();
break;
}
r.NextDouble();
r.Next(100, 1999);
}
return s;
}
}
}
Nothing was added in the ASP.NET part of the webpage.
KR