Try our conversational search powered by Generative AI!

Help! LastActivityDate shows CurrentDatetime from Membership Class

Vote:
 

Thanks In Advance!

 

I am showing a list of users with LastActivityDate but I am getting LastActivityDate as CurrentDatetime from Membership.GetUser Method,Can anybody tell me why this?

#42965
Sep 08, 2010 11:00
Vote:
 

Are you getting any data from the user's profile at the same time? I think that might update the activity date.

#42973
Sep 08, 2010 11:17
Vote:
 

Which MembershipProvider is this?

/johan

#42990
Sep 08, 2010 13:04
Vote:
 

I am using Sql Membership Provider

The lines of code are

 MembershipUser mUser = Membership.GetUser("useremail@xyz.com");
 EPiServerProfile profile = EPiServerProfile.Get(user);

#42991
Sep 08, 2010 13:17
Vote:
 

Try commenting out the EPiServerProfile call and see if it stops updating the activity date.

#42992
Sep 08, 2010 13:26
Vote:
 

It seems this is very low-level. It's actually the stored procedure (!) aspnet_Profile_Get_Properties which updates the membershipUser directly in the database with the last activity date. You can of course change the stored procedure to omit this update. Not a very good solution, but perhaps the only one :(

#42993
Sep 08, 2010 13:34
Vote:
 

Yes, the SqlProfileProviders implementation in stored proc. aspnet_Profile_GetProperties do actually
update the lastActivitYDate field:

...
    IF (@@ROWCOUNT > 0)
    BEGIN
        UPDATE dbo.aspnet_Users
        SET    LastActivityDate=@CurrentTimeUtc
        WHERE  UserId = @UserId
    END
...

Edit: Sorry, didnt see Magnus post above, thus the duplicate...

/johan

#42994
Edited, Sep 08, 2010 13:38
Vote:
 

Thks!

Thats working but if i have to show info from profile than what i have to do?

#42995
Sep 08, 2010 13:43
Vote:
 

Then you'll have to change the stored procedure, remove the section Johan pasted in his post above.

#42996
Sep 08, 2010 13:52
Vote:
 

Another (ugly) option would be to call the UpdateUser() on the MembershipUser right after getting the proile.
That would write back the old activityDate previously read...atleast theoretically, I havent tried this myself.

MembershipUser mUser = Membership.GetUser("nospam@localhostuseremailnospam@localhost@nospam@localhostxyz.comnospam@localhost");
 EPiServerProfile profile = EPiServerProfile.Get(user);
mUser.UpdateUser();

/johan

#42998
Sep 08, 2010 14:05
Vote:
 

Perhaps, or explicitly getting the date from the membership user, storing it in a local variable while reading the profile and then setting it back in the membership user. But any way you'd have to remember to do that in every place of the code where you get the profile.

You could of course subclass the profile and put the hack in there somewhere. Or somehow change the call to the stored procedure so that it calls some custom implementation with a different name - that way you'll at least notice if the customized procedure is not available in the database (I mean, if you run the site with a different database or some update for aspnet rewrites the stored procedure).

#42999
Sep 08, 2010 14:15
Vote:
 

I think SP option is better than Updateprofile,anyway Thanks for your efforts.

 

#43000
Sep 08, 2010 14:18
Vote:
 

Membership.GetUser("userNN", false);

 

will not update lastactivitydate. (or am I missing something here...)

#43036
Edited, Sep 09, 2010 12:56
Vote:
 

The problem is the call to the EPiServerProfile/ProfileBase (which is used in the same context), which updates the MembershipUser's LastActivityDate on the database level.

#43043
Sep 09, 2010 16:27
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.