我会建议去Providers
。这些在ASP.NET中可用很长时间,并且仍在使用。它们的实现对于两者(WebForms和MVC)都是相同的,所以我建议阅读关于它们的综合教程
该Profile
功能正是提供用户特定信息的地方。它可以很容易地扩展并表示扩展点到Membership
. 我们正在使用我们的一个Profile
类:
public class ProjectProfile : ProfileBase
{
// TODO custom properties
}
在 web.config 中配置
<profile defaultProvider="ProjectProfile"
inherits="MyLibrary.ProjectProfile, MyLibrary">
<providers >
<clear/>
<add name="ProjectProfile" type="MyLibrary.ProjectProfileProvider, MyLibrary" />
</providers>
</profile>
所以,System.Web.HttpContext.Current.Profile as ProjectProfile
有需要的信息。