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?

#42965 Sep 08, 2010 11:00
  • Member since: 2008
     

    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
  • Member since: 1996
     

    Which MembershipProvider is this?

    /johan

    #42990 Sep 08, 2010 13:04
  •  

    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
  • Member since: 2008
     

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

    #42992 Sep 08, 2010 13:26
  • Member since: 2008
     

    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
  • Member since: 1996
     

    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
  •  

    Thks!

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

    #42995 Sep 08, 2010 13:43
  • Member since: 2008
     

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

    #42996 Sep 08, 2010 13:52
  • Member since: 1996
     

    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
  • Member since: 2008
     

    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
First   1 2   Last