当前位置: 移动技术网 > IT编程>开发语言>.net > MVC Remote 服务器验证

MVC Remote 服务器验证

2018年10月27日  | 移动技术网IT编程  | 我要评论

187白银网,楚天都市网,赛尔号卡伦尼怎么打

用此验证必须在controller中编写返回值为jsonresult的action

 1 public jsonresult checkusername(string username)
 2 {
 3   efhelper<studentdbentities> dbcontext = efhelper<studentdbentities>.getinstance();
 4   userinfo result = dbcontext.getsingle<userinfo>(item => item.username == username);
 5   bool isexists;
 6   if (result != null)
 7   {
 8     isexists = false;
 9     return json(isexists, jsonrequestbehavior.allowget);
10   }
11   else
12   {
13   isexists = true;
14     return json(isexists, jsonrequestbehavior.allowget);
15   }
16 
17 }

实体类代码:

1 [remote("checkusername", "user", errormessage = "用户名已存在")]
2         public string username { get; set; }

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网