views:

302

answers:

2

I'm working on a WCF service that requires Membership and Profile access.

I got the Membership stuff working by using System.Web.Security.Membership class and calling CreateUser() and ValidateUser() but i can't get the Profile to work. I don't even know what class to call, all the samples that i have seen are for ASP.net like the one i posted below,

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        txtFirstName.Text = Profile.FirstName;
        txtLastName.Text = Profile.LastName;
        int foo = Profile.Age;
    }
}

when i try that in my WCF endpoint the Profile object isn't available and I can't find any other way to access it.

can someone please point me to the write direction on how to access profile details?

A: 

Did you enable asp.net compatibilities for your WCF service? Did you host your WCF service with IIS, not the windows service?

In order to use that behavior, you need to do both of above.

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class MyService : IMyService
{
}
codemeit
I added the [AspNetCompatibilityRequirements] to my operation contract, and also web.config.<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> but "Profile." returns nothing on intelisence,
Keivan
A: 

I think this question covers your problem:

Why was the Profile provider not built into Web Apps?

I would try using the Web Profiler Builder mentioned in one of the answers - seems like something that could help you. An alternative would be to handcode a strongly typed wrapper around the profile in a way similar to the autogenerated one.

Robert Wilczynski