how to use Profile.GetProfile() in a library class?

后端 未结 3 1948
野的像风
野的像风 2021-01-20 01:24

I cant figure out how to use Profile.GetProfile() method in a library class. I tried using this method in a Page.aspx.cs and it worked perfectly.

How ca

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-20 02:07

    In ASP.NET, Profile is a hook into the HttpContext.Current.Profile property, which returns a dynamically generated object of type ProfileCommon, derived from System.Web.Profile.ProfileBase.

    ProfileCommon apparently includes a GetProfile(string username) method, but you wont find it documented officially in MSDN (and it wont show up in intellisense in visual studio) because most of the ProfileCommon class is dynamically generated when your ASP.NET application is compiled (The exact list of properties and methods will depend on how 'profiles' are configured in your web.config). GetProfile() does get a mention on this MSDN page, so it seems to be real.

    Perhaps in your library class, the problem is that the configuration info from web.config is not being picked up. Is your library class part of a Solultion that includes a Web Application, or are you just working on the library in isolation?

提交回复
热议问题