hello hope got answer problem im trying make hash password user , database type mysql , , im using asp.net mvc 2015 im still having troubles because could'nt make hash , , im trying md5 still can't know how modify in mysql.
this user model public class user {
[key] [required] [display(name = "user name")] public string username { get; set; } //forigen key of role id [required] [display(name = "role id")] public int roleid { get; set; } [foreignkey("roleid")] public virtual role role { get; set; } [required] [stringlength(100, errormessage = "the {0} must @ least {2} characters long.", minimumlength = 6)] [datatype(datatype.password)] public string password { get; set; } }
public class userscontroller : controller { private dbcontaxt db = new dbcontaxt();
// get: users public actionresult index() { var user = db.user.include(u => u.role); return view(user.tolist()); } // get: users/details/5 public actionresult details(int? id) { if (id == null) { return new httpstatuscoderesult(httpstatuscode.badrequest); } user user = db.user.find(id); if (user == null) { return httpnotfound(); } return view(user); } // get: users/create public actionresult create() { viewbag.roleid = new selectlist(db.role, "roleid", "rolename"); return view(); } [httppost] [validateantiforgerytoken] public actionresult create([bind(include = "username,roleid,password")] user user) { if (modelstate.isvalid) { db.user.add(user); db.savechanges(); return redirecttoaction("index"); } viewbag.roleid = new selectlist(db.role, "roleid", "rolename", user.roleid); return view(user); } viewbag.roleid = new selectlist(db.role, "roleid", "rolename", user.roleid); return view(user); } [httppost] [validateantiforgerytoken] public actionresult edit([bind(include = "username,roleid,password")] user user) { if (modelstate.isvalid) { db.entry(user).state = entitystate.modified; db.savechanges(); return redirecttoaction("index"); } viewbag.roleid = new selectlist(db.role, "roleid", "rolename", user.roleid); return view(user); }
Comments
Post a Comment