none
ProfileManager.DeleteInactiveProfiles is not deleting any profiles RRS feed

  • Question

  • I have an ASP.NET 4.5 application that allows anonymous profiles using the standard SqlProfileProvider.  I am trying to write a simple function to purge inactive anonymous profiles.  However, no profiles are ever deleted - even though I know there are some.  Here is my purging code:

                // Work out the start date of inactivity
                var purgeBefore = DateTime.Now.AddDays(-7);
    
                // Delete all profiles inactvie since that date.
                var count = ProfileManager.DeleteInactiveProfiles(ProfileAuthenticationOption.Anonymous, purgeBefore);
    This is the configuration of the profile provider in my Web.Config file:
          <providers>
            <clear/>
            <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ConnectionStringName" applicationName="ApplicationName"/>
          </providers>
    The anonymous profiles work fine, but I cannot get them to delete.  What am I doing wrong?


    • Edited by Wayne Allen Thursday, October 17, 2013 12:09 AM Mistype
    Thursday, October 17, 2013 12:08 AM

Answers

  • Hi Wayne,

    Welcome to MSDN forum.

    I think this thread is specific to ASP. NET forum. This form is to discuss problems about CLR development. Please post a new thread on that forum for more effective response. http://forums.asp.net/. Thank you for your understanding.

    Per my understanding, I think you have passed the incorrect parameter to DeleteInactiveProfiles method.

    Use theauthenticationOption parameter to specify whether you want only anonymous profiles, only authenticated profiles, or all profiles to be searched. Of the searched profiles, any profile with aLastActivityDate that occurs on or before the specified userInactiveSinceDate parameter value is deleted.—MSDN

    I mark some small modification based on your code, please have a look and try on it.

    var count = ProfileManager.DeleteInactiveProfiles(ProfileAuthenticationOption.Anonymous, DateTime.Now.AddDays(7));

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 18, 2013 2:31 AM
    Moderator