checknamehandler.ashx
来自「电子商务网站转载而来[展开所有目录] [建议增加分类] (重要) 」· ASHX 代码 · 共 49 行
ASHX
49 行
<%@ WebHandler Language="C#" Class="CheckNameHandler" %>
using System;
using System.Web;
using BLL;
public class CheckNameHandler : IHttpHandler {
public string txtGetName = string.Empty;
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string flag = string.Empty;
txtGetName = context.Request.QueryString["userName"].ToString();
User bll = new User();
bool txtIsName = bll.CheckName(txtGetName);
if (!CheckNameSize(txtGetName)) {
flag = "0";
}
else if (!txtIsName)
{
flag = "2";
}
else {
flag = "1";
}
context.Response.Write(flag);
}
public bool CheckNameSize(string nName) {
return (System.Text.RegularExpressions.Regex.IsMatch(nName, @"^[\w]{6,10}$"));
}
public bool IsReusable {
get {
return false;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?