我是asp.net的初学者编程。我使用这个功能强大的tutorial ...
对ASP.NET中的标识进行了mysql集成问题是: 在使用此功能创建员工数据后,如何创建默认密码(例如:默认):
控制器:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(dbemployee dbemployee)
{
if (ModelState.IsValid)
{
db.dbemployees.Add(dbemployee);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.iDept = new SelectList(db.dbtodepts, "iDept", "sDept", dbemployee.iDept);
ViewBag.iSmokers = new SelectList(db.dbtoflagies, "iFlag", "sFlag", dbemployee.iSmokers);
ViewBag.iEmpGender = new SelectList(db.dbtogenders, "iGender", "sGender", dbemployee.iEmpGender);
ViewBag.iGrade = new SelectList(db.dbtogrades, "iGrade", "sGrade", dbemployee.iGrade);
ViewBag.iJob = new SelectList(db.dbtojobs, "iJob", "sJobName", dbemployee.iJob);
ViewBag.iEmpLastEdu = new SelectList(db.dbtolasteducations, "iLastEdu", "sLastEdu", dbemployee.iEmpLastEdu);
ViewBag.iEmpMaritalStat = new SelectList(db.dbtomaritalstats, "iMaritalStat", "sMaritalStat", dbemployee.iEmpMaritalStat);
ViewBag.iEmpReligion = new SelectList(db.dbtoreligions, "iReligion", "sReligion", dbemployee.iEmpReligion);
return View(dbemployee);
}
当然这个函数是由脚手架自动生成的,我的想象是应该添加这样的代码:
RegisterViewModel reg = new RegisterViewModel();
reg.Password.Insert("default").GetHashCode.ToString();
正如我们所知,上面的代码是完全错误的.. 对不起我的英语技能,但我希望有人理解我的情况。谢谢.. :))
答案 0 :(得分:2)
ASP.NET Identity不包含默认密码创建方法,因为它在密码重置链接上进行中继,这是处理密码的更安全的方法。你有没有在你的应用程序中考虑过这种方法?