是否有可能访问配置文件,而无需更新LastActivityDate? [英] Is it possible to access a profile without updating LastActivityDate?
问题描述
在asp.net(使用MVC,但这种情况发生在普通太)
In asp.net (using MVC, but this happens in regular too)
Profile.GetProfile(username);
将更新LastActivityDate为该用户。这是当别人在查看该用户的个人资料并不打算。
will update the LastActivityDate for that user. This is not intended when someone else is viewing that user's profile.
在会员类,你可以指定是否与第二个参数更新这个日期,就像这样:
In the membership class you can specify whether to update this date with a second param, like so:
Membership.GetUser(username, false); // doesn't update LastActivityDate
Membership.GetUser(username, true); // updates LastActivityDate
反正有这样做的个人资料提供类似的东西没有写我自己的供应商?
Is there anyway to do something similar in the Profile provider without writing my own provider?
推荐答案
您可以使用一个丑陋的解决办法,其中包括改变 aspnet_Profile_GetProperties
存储过程。这一个是负责获取属性在访问用户配置文件。
You might use one ugly workaround which includes changing aspnet_Profile_GetProperties
stored procedure. This one is responsible for getting the properties while accessing user profile.
打开这个程序,你会发现底部下面code:
Open this procedure and you will find following code at the bottom:
IF (@@ROWCOUNT > 0)
BEGIN
UPDATE dbo.aspnet_Users
SET LastActivityDate=@CurrentTimeUtc
WHERE UserId = @UserId
END
为了停止更新 LastActivityDate
删除它。你仍然会得到 LastActivityDate
打电话时 Membership.GetUser(用户名,真实)更新;
。
Remove it in order to stop updating the LastActivityDate
. You will still get LastActivityDate
updated when calling Membership.GetUser(username, true);
.
这篇关于是否有可能访问配置文件,而无需更新LastActivityDate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!