Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to access a profile without updating LastActivityDate?

In asp.net (using MVC, but this happens in regular too)

Profile.GetProfile(username);

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?

like image 914
WildJoe Avatar asked Aug 09 '10 07:08

WildJoe


1 Answers

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.

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

Remove it in order to stop updating the LastActivityDate. You will still get LastActivityDate updated when calling Membership.GetUser(username, true);.

like image 162
Radek Stromský Avatar answered Oct 01 '22 18:10

Radek Stromský