ok-admin框架,第一天登录



@{
ViewBag.Title = "员工登录";
Layout = null;
}





员工登录

@**@




@*

*@

















后端代码:

///


/// 登录验证
///

///
///
[HttpPost]
public string Login(SysUser _user)
{
YuanGongDb dbcontext = new YuanGongDb();
var username = _user.username;
var password = _user.PassWord;
ResponseData res = new ResponseData();//返回的数据格式code,msg
var userdata = dbcontext.SysUser.Where(o => o.username == username && o.PassWord == password).FirstOrDefault();
if (userdata != null)
{
Session["UID"] = userdata.id;
Session["RID"] = userdata.RID;
Session["Realname"] = userdata.Realname;
res.code = 0;
res.msg = "登录成功了";
var data = JsonConvert.SerializeObject(res);
return data;
}
else
{
res.code = 1;
res.msg = "用户名或密码错误";
var data = JsonConvert.SerializeObject(res);
return data;
}