Is it possible to access a profile without updating LastActivityDate?

好久不见. 提交于 2019-11-30 18:41:39

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

You might look at using a provider that someone else has written, rather than write your own.

This one on Scott Guthrie's blog includes stored procedures which could be called directly by your own code to get the information:

http://weblogs.asp.net/scottgu/archive/2006/01/10/435038.aspx

This page has an msi download which installs a sample application for working with custom Profile data. The table based profile performs a lot better than the default on, where all of the profile data is contained in a single database field. The table based one is also a lot easier to query directly, which will help you with your question. The stored procedure from the sample schema is called getCustomProfileData

Otherwise, just query the database directly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!