是否可以在不更新 LastActivityDate 的情况下访问个人资料?

发布于 2024-09-13 07:05:24 字数 397 浏览 2 评论 0原文

在 asp.net 中(使用 MVC,但这也经常发生)

Profile.GetProfile(username);

将更新该用户的 LastActivityDate。当其他人正在查看该用户的个人资料时,这不是有意的。

在成员资格类中,您可以指定是否使用第二个参数更新此日期,如下所示:

Membership.GetUser(username, false); // doesn't update LastActivityDate
Membership.GetUser(username, true); // updates 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云胡 2024-09-20 07:05:27

您可能会考虑使用其他人编写的提供程序,而不是编写您自己的提供程序。

Scott Guthrie 博客上的这个包含存储过程,您可以通过自己的代码直接调用这些存储过程来获取信息:

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

此页面有一个 msi 下载,它安装了一个示例应用程序,用于使用自定义配置文件数据。基于表的配置文件的性能比默认配置文件要好得多,默认配置文件的所有配置文件数据都包含在单个数据库字段中。基于表格的查询也更容易直接查询,这将帮助您解决问题。示例架构中的存储过程称为getCustomProfileData

否则,只需直接查询数据库

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.

影子的影子 2024-09-20 07:05:26

您可能会使用一种丑陋的解决方法,其中包括更改 aspnet_Profile_GetProperties 存储过程。这个负责在访问用户配置文件时获取属性。

打开此程序,您将在底部找到以下代码:

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

将其删除以停止更新 LastActivityDate。调用 Membership.GetUser(username, true); 时,您仍会更新 LastActivityDate

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文