Question

ASP.NET profile properties are trivially available to the code-behind of an ASPX web page courtesy of the HttpContext.Current.Profile object.

In a .svc web service, how does one bring ProfileCommon and paraphernalia into scope?

Was it helpful?

Solution

In the web.config file is a commented out section controlling whether the profile service is enabled. Enabling it changes the generated code and HttpContext becomes available.

You don't have the class that descends from ProfileBase to present profile properties as strongly typed properties. This however is hardly a disaster, you just use

  HttpContext.Current.Profile.GetPropertyValue(string propName)

and cast the result.

OTHER TIPS

The usual way I use for accessing profile data via classes in App_Code folder within a web app worked for me:

MembershipUser mu = Membership.GetUser(userName, false);
ProfileCommon p = (ProfileCommon)ProfileBase.Create(mu.UserName, true);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top