Share via

How to: Enable the WCF Profile Service

This topic shows how to configure the ASP.NET profile service on a Web server to make it available to clients that use the Windows Communication Foundation (WCF). The topic also shows how to perform the following tasks:

To configure the ASP.NET profile service as a WCF service

  1. If you do not already have an ASP.NET Web application, create one.

  2. Add a WCF service file (.svc) file to the Web site that contains the following directive to reference the ProfileService class:

    <%@ ServiceHost Language="VB"
    Factory="System.Web.ApplicationServices.ApplicationServicesHostFactory" %>
    <%@ ServiceHost Language="C#"
    Factory="System.Web.ApplicationServices.ApplicationServicesHostFactory" %>
  3. Save the .svc file and close it.

  4. Make the following configuration settings in the Web.config file to configure the service:

    • Define the endpoint contract in the services element and the service behavior in the behaviors element. Include the bindingNamespace property in the endpoint contract as shown in the following example in order to prevent an exception in some proxy generation tools. For more information about WCF endpoints, see Windows Communication Foundation Endpoints.

    • Configure the serviceHostingEnvironment element for ASP.NET compatibility. For more information about hosting WCF services, see WCF Services and ASP.NET.

    The following example shows the system.serviceModel element from a Web.config file that shows the configuration settings described in the previous list.

        <service name="System.Web.ApplicationServices.ProfileService"
          <endpoint contract=

To enable the profile service and expose properties

  1. If you have not already defined profile properties for the Web application, define them in the Web.config file.

    The following example shows the definition for two profile properties.

          <add name="Birthday" /> 
          <add name="FavoriteColor" />

    For more information defining profile properties, see Defining ASP.NET Profile Properties.

  2. In the Web.config file, enable the profile service and mark which properties are available as either read-only properties or as read-write properties.

    The following example shows how to enable the profile service and set the accessibility for profile properties.

          <profileService enabled="true"
            readAccessProperties="Birthday, FavoriteColor"
            writeAccessProperties="Birthday, FavoriteColor" >


If you save sensitive data in profile properties, access the profile service over the secure sockets layer (SSL, by using HTTPS protocol). Also make sure that the data is stored securely. For more information, see Securing Profile Properties. For more information about how to set up a WCF service to run over SSL, see Transport Security. For more information about how to set up SSL, see Configuring Secure Sockets Layer (IIS 6.0 Operations Guide) and Configuring Secure Sockets Layer in IIS 7.0 on the Microsoft Web site.

See Also


Walkthrough: Using ASP.NET Application Services


Windows Communication Foundation Authentication Service Overview

Windows Communication Foundation Role Service Overview

Other Resources

Configuring Services