是否可以在不更新 LastActivityDate 的情况下访问个人资料?
在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能会考虑使用其他人编写的提供程序,而不是编写您自己的提供程序。
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.
您可能会使用一种丑陋的解决方法,其中包括更改
aspnet_Profile_GetProperties
存储过程。这个负责在访问用户配置文件时获取属性。打开此程序,您将在底部找到以下代码:
将其删除以停止更新
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:
Remove it in order to stop updating the
LastActivityDate
. You will still getLastActivityDate
updated when callingMembership.GetUser(username, true);
.