SaaS CMS has officially launched! Learn more now.

Help! LastActivityDate shows CurrentDatetime from Membership Class


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?

Sep 08, 2010 11:00

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

Sep 08, 2010 11:17

Which MembershipProvider is this?


Sep 08, 2010 13:04

I am using Sql Membership Provider

The lines of code are

 MembershipUser mUser = Membership.GetUser("");
 EPiServerProfile profile = EPiServerProfile.Get(user);

Sep 08, 2010 13:17

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

Sep 08, 2010 13:26

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 :(

Sep 08, 2010 13:34

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

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

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


Edited, Sep 08, 2010 13:38


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

Sep 08, 2010 13:43

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

Sep 08, 2010 13:52

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);


Sep 08, 2010 14:05

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).

Sep 08, 2010 14:15

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


Sep 08, 2010 14:18

Membership.GetUser("userNN", false);


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

Edited, Sep 09, 2010 12:56

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.

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.