首先,添加一个一般处理程序
注释很详细了,有不懂的欢迎评论
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.SessionState;
namespace Project_Practice
{
/// <summary>
/// Handler1 的摘要说明
/// </summary>
public class Handler1 : IHttpHandler,IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
//选取的颜色
Color[] colors = {
Color.White };
//通过Bitmap构造Image
Image img = new Bitmap(100, 60);
//Graphics绘画Image
Graphics graphics = Graphics.FromImage(img);
Random random = new Random(DateTime.Now.Millisecond);
//验证码的四位数
int charNum1 = random.