Implement a web service to delete orphaned user profiles

The following tutorial demonstrates creating a full implementation of a web service that takes care of removing orphaned UserProfile objects from Sitefinity CMS.

Define your DTOs and routes

The service will support deleting orphaned user profiles for a single user or for all users from a specified MembershipProvider. To do that you need to define two Request DTOs handling the delete by user ID and delete by providerName operations. Both Request DTO have the route specified. In this case the route is the same, but when used for deleting orphaned profiles for a single user it accepts a UserId parameter. The same route is used  for deleting all orphaned profiles for users under a particular membership provides, when a ProviderName parameter is passed.

You also need to define the matching Response DTOs:

Implement the service

In the service implementation you must implement two separate methods responsible for handling the business logic matching the respective Request DTO and route you already defined. The first method is responsible for deleting orphaned profiles for a single user, while the second one takes care of deleting orphaned profiles for all users in a specified membership provider.

Implement the plugin and register the service

In the plugin you must implement the IPlugin interface and inside the Register method specify the type of the service you want to register:

Once you have all the components ready you must register the plugin in your Global.asax:

As a result, you can consume your new web service by calling it:


Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?