private void validate_username(HttpContext context) { string user_name = OSRequest.GetString("param"); //如果为Null,退出 if (string.IsNullOrEmpty(user_name)) { context.Response.Write("{ \"info\":\"请输入用户名\", \"status\":\"n\" }"); return; } Model.configs.userconfig userConfig = new BLL.configs.userconfig().loadConfig(); //过滤注册用户名字符 string[] strArray = userConfig.regkeywords.Split(','); foreach (string s in strArray) { if (s.ToLower() == user_name.ToLower()) { context.Response.Write("{ \"info\":\"用户名不可用\", \"status\":\"n\" }"); return; } } BLL.users.users bll = new BLL.users.users(); //查询数据库 if (bll.Exists(user_name.Trim())) { context.Response.Write("{ \"info\":\"用户名已重复\", \"status\":\"n\" }"); return; } context.Response.Write("{ \"info\":\"用户名可用\", \"status\":\"y\" }"); return; }