asp.net mvc - Show personal profile in MVC -
here model class represent properties of user profile.
public class profile { public int profileid { get; set; } public string username { get; set; } public string age { get; set; } public string gender { get; set; } public string password { get; set; } public string email { get; set; } } when users create profile, profiles saved in database. when log in using email , password want show them personal profile only. how can this? beginner in mvc..help me explaining detail please..
you have make profile controller , put getprofile method. getprofile load user's data , show them customer.
public class profile : controller { pubmlic actionresult getprofile() { // user id in session instance, or somewhere else, here put 5 example must dynamic int userid = 5; // retieve info , put in model variable profile userprofil = getuser(userid); return view(model); } }
where getuser(userid) entry point user details, instance
public static class mydataaccesslayerforuser { public static profile getuser(userid) { string sql = "select * database user = @user"; // add @user parameter // perform query ... profile data = userreadondb; return data; } } then, have create view shown elements user, in views/profile, create view (.cshtml) named "getprofile?cshtml" , have use model retreved in controller that:
@model yourprojectnamespacetotheprofileobject.profile @html.display(m => m.username) @html.display(m => m.age) so response question, have there authentication made asp.net mvc, (it called identity), , advice store date of birth instread of age of user :-)
Comments
Post a Comment