1,前台页面
2,后端代码
<%@ WebHandler Language="C#" Class="VerifyUserNameHandler" %>
using System;
using System.Web;
using System.Collections;
using System.Collections.Generic;
public class VerifyUserNameHandler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
//context.Response.ContentType = "text/plain";
string _name = context.Request.QueryString["para"];
_name = string.IsNullOrEmpty(_name) ? "" : _name;
System.Threading.Thread.Sleep(3000);//用线程来模拟数据库查询工作
string[] Names = new string[] { "Sandy", "阿非", "abc" };//这里用Names数组来代替数据库中的结果集
if (Array.IndexOf<string>(Names, _name) == -1)
{
context.Response.Write("恭喜,用户名可以使用。");
}
else
{
context.Response.Write("抱歉,用户名已被使用。");
}
}
public bool IsReusable {
get {
return false;
}
}
}