最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net随机验证码(使用ashx)
时间:2008-06-03 编辑:简简单单 来源:一聚教程网
ValidateCode.ashx
<%@ WebHandler Language="C#" Class="ValidateCode" %>
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Drawing;
public class ValidateCode : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);//特别注意,如不加,单击验证图片'看不清换一张',无效果.
this.CreateCheckCodeImage(GenerateCheckCode(context),context);
}
public bool IsReusable
{
get
{
return false;
}
}
private string GenerateCheckCode(HttpContext context)
{
int number;
char code;
string checkCode = String.Empty;
System.Random random = new Random();
for (int i = 0; i < 6; i++)
{
number = random.Next();
-
上一个: Asp.Net页面输出到EXCE
相关文章
- ASP.NET中画图形验证码的实现代码 01-06
- asp.net 验证码控件 05-03
- 三款asp.net 验证码代码 08-26
- ASP.net实现验证码技术(网上收集) 01-12
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24