- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我似乎无法找到原因或位置,但即使我将 Membership.GetUser(userName, false) 设置为 false,LastActivityDate 也会始终更新,因此它不会更新 LastActivityDate。我在其他任何地方也没有访问 GetUser 的任何其他代码。所以我在配置文件中创建了一个名为 LastActivity 的属性,这有点像,但我不明白为什么每次刷新页面时 GetUser 总是更新 LastActivityDate。
private void SwitchMode(Mode mode)
{
ProfileCommon profile = Profile.GetProfile(UserName);
MembershipUser mu = Membership.GetUser(UserName, false);
bool isOnline = minutes(DateTime.Now - profile.LastActivity) >= Membership.UserIsOnlineTimeWindow ? false : true;
lblActivity.Text = mu.LastActivityDate.ToString();
switch (mode)
{
case global::Mode.Readonly:
profileAvatar.Visible = true;
profileDetails.Visible = true;
profileForm.Visible = false;
lblUserName.Text = UserName;
if (profile.Website != null)
{
lblWebsite.Visible = false;
lnkWebsite.Visible = true;
}
else
{
lblWebsite.Visible = true;
lnkWebsite.Visible = false;
}
lblSummary.Text = profile.Summary;
lnkWebsite.Text = profile.Website == string.Empty ? "-" : profile.Website;
lnkWebsite.NavigateUrl = profile.Website == string.Empty ? "-" : profile.Website;
lblLocation.Text = profile.Address.StateRegion + ", " + profile.Address.Country;
lblFullname.Text = profile.FirstName + " " + profile.LastName;
lblEmail.Text = profile.ShareEmail && mu != null ? mu.Email : "-";
lblGender.Text = profile.Gender == 0 ? "Male" : profile.Gender == 1 ? "Male" : "Female" ;
lblAge.Text = Convert.ToString(Math.Floor(DateTime.Today.Subtract(profile.BirthDate).TotalDays / 365.25));
lblMemberfor.Text = PrintTimeSpan1(DateTime.Now - mu.CreationDate);
lblVisited.Text = profile.Visits.ToString();
lblSeen.Text = PrintTimeSpan1(DateTime.Now - profile.LastActivity) + " ago";
lblProfileViews.Text = profile.Views.ToString();
if (HttpContext.Current.User.Identity.Name != UserName)
{
profile.Views += 1;
profile.Save();
}
if (isOnline)
{
lblStatus.Text = "online";
}
else
{
lblStatus.Text = "offline";
}
break;
case global::Mode.Edit:
profileAvatar.Visible = true;
profileDetails.Visible = false;
profileForm.Visible = true;
lblUserName.Text = UserName;
txtFirstName.Text = profile.FirstName;
txtLastName.Text = profile.LastName;
radioGender.SelectedIndex = profile.Gender;
ddlDay.SelectedValue = profile.BirthDate.Day.ToString();
ddlMonth.SelectedValue = profile.BirthDate.Month.ToString();
ddlYear.SelectedValue = profile.BirthDate.Year.ToString();
txtWebsite.Text = profile.Website;
ddlOccupation.SelectedValue = (profile.Occupation == string.Empty ? "0" : profile.Occupation);
txtStreet.Text = profile.Address.Street;
txtZipCode.Text = profile.Address.ZipCode;
txtStateRegion.Text = profile.Address.StateRegion;
ddlCountry.SelectedValue = (profile.Address.Country == string.Empty ? "0" : profile.Address.Country);
txtAvatar.Text = profile.Forum.AvatarUrl;
txtForumSignature.Text = profile.Forum.Signature;
chkNewsLetter.Checked = profile.NewsLetter;
chkShareEmail.Checked = profile.ShareEmail;
txtSummary.Text = profile.Summary;
break;
case global::Mode.Insert:
profileAvatar.Visible = false;
profileDetails.Visible = false;
profileForm.Visible = true;
break;
}
}
最佳答案
您对 Profile.GetProfile(UserName) 的调用正在更新日期。我有同样的问题。在这里查看我的问题:Is it possible to access a profile without updating LastActivityDate?基本上,您必须修改获取配置文件详细信息的存储过程并删除一小段代码。
关于c# - Membership.GetUser(userName, isOnline) 总是更新 LastActivityDate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9611005/
在 asp.net 中(使用 MVC,但这也经常发生) Profile.GetProfile(username); 将更新该用户的 LastActivityDate。当其他人正在查看该用户的个人资料时
LastActivityDate 应该何时更新?当我以经过身份验证的用户身份单击 Web 应用程序中的任何其他页面时,LastActivityDate 不会更新。 我想当用户单击任何页面时都应该更新它
我正在使用 ASP.NET MVC 并创建一个公共(public)网站。我需要跟踪在线用户。我看到在 asp.net 中执行此操作的标准方法是跟踪 LastActivityDate。我的问题是我应该什
我似乎无法找到原因或位置,但即使我将 Membership.GetUser(userName, false) 设置为 false,LastActivityDate 也会始终更新,因此它不会更新 Las
我是一名优秀的程序员,十分优秀!