有没有办法通过使用ASPNETDB.MDF中的aspnet_user表获取用户在asp.net中的最后登录日期和时间? [英] is there any way of getting the last login date and time of the user in asp.net by using aspnet_user table from ASPNETDB.MDF?
本文介绍了有没有办法通过使用ASPNETDB.MDF中的aspnet_user表获取用户在asp.net中的最后登录日期和时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从ASPNETDB.MDF创建的默认用户表中收集此信息,当使用登录控件时,我是否也可以获得上次登录时间?
i am trying to gather this information from the default user table that is created by ASPNETDB.MDF when using login control is there any way i can get last login time also?
string str = "select username, LastActivityDate from aspnet_Users";
SqlDataAdapter da = new SqlDataAdapter(str, con);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
显示输出如下:
a2ulthakur 17- 04-2013 07:20:02
但是没有显示准确的时间。
its showing output like this:
a2ulthakur 17-04-2013 07:20:02
but its not showing the accurate time.
推荐答案
试试此代码
try this code
MembershipUser mu = Membership.GetUser("username");
EmailLabel.Text = mu.Email;
IsOnlineLabel.Text = mu.IsOnline.ToString();
LastLoginDateLabel.Text = mu.LastLoginDate.ToString();
CreationDateLabel.Text = mu.CreationDate.ToString();
LastActivityDateLabel.Text = mu.LastActivityDate.ToString();
也参考msdn links
MembershipUser Class [ ^ ]
MembershipUser.LastActivityDate Property [ ^ ]
这篇关于有没有办法通过使用ASPNETDB.MDF中的aspnet_user表获取用户在asp.net中的最后登录日期和时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文