在 asp.net 中(使用 MVC,但这也经常发生)
Profile.GetProfile(username);
将更新该用户的 LastActivityDate。当其他人正在查看该用户的个人资料时,这不是故意的。
在成员资格类中,您可以指定是否使用第二个参数更新此日期,如下所示:
Membership.GetUser(username, false); // doesn't update LastActivityDate
Membership.GetUser(username, true); // updates LastActivityDate
无论如何,在不编写自己的提供程序的情况下,是否可以在 Profile 提供程序中执行类似的操作?
最佳答案
您可能会使用一种丑陋的解决方法,其中包括更改 aspnet_Profile_GetProperties
存储过程。这个负责在访问用户配置文件时获取属性。
打开这个程序,你会在底部找到以下代码:
IF (@@ROWCOUNT > 0)
BEGIN
UPDATE dbo.aspnet_Users
SET LastActivityDate=@CurrentTimeUtc
WHERE UserId = @UserId
END
删除它以停止更新
LastActivityDate
.你仍然会得到 LastActivityDate
调用时更新 Membership.GetUser(username, true);
.
关于asp.net - 是否可以在不更新 LastActivityDate 的情况下访问个人资料?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3438200/