[Mono-aspnet-list] Profile_MigrateAnonymous() event in Global.asax

Mark Walmsley mail at markwalmsley.net
Fri Aug 7 17:42:48 EDT 2009


I am trying to use the Profile_MigrateAnonymous() event in a Global.asax
file, but it does not seem to fire.

I have no idea whether this event is currently supported by Mono.

I have added the following to my Web.Config file:

     <authentication mode="Forms">
      <forms name=".ASPXAUTH" loginUrl="login.aspx" protection="All"
timeout="30" path="/" requireSSL="false" slidingExpiration="true"
defaultUrl="home.aspx" cookieless="UseCookies"
enableCrossAppRedirects="false"/>
    </authentication>
    <membership defaultProvider="MySqlMembershipProvider"
userIsOnlineTimeWindow="15">
      <providers>
        <add name="MySqlMembershipProvider" ... passwordFormat="Encrypted"/>
      </providers>
    </membership>
    <profile enabled="true" automaticSaveEnabled="true"
defaultProvider="MySqlProfileProvider">
      <providers>
        <add name="MySqlProfileProvider" ... />
      </providers>
      <properties>
        <add name="Colour" allowAnonymous="true"/>
      </properties>
    </profile>
    <httpModules>
      <add name="Profile" type="System.Web.Profile.ProfileModule,
System.Web, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"/>
      <add name="AnonymousIdentification"
type="System.Web.Security.AnonymousIdentificationModule, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    </httpModules>
    <anonymousIdentification enabled="true" domain=""
cookieName=".ASPXANONYMOUS" cookieTimeout="100000" cookiePath="/"
cookieRequireSSL="false" cookieSlidingExpiration="true"
cookieProtection="All" cookieless="UseCookies"/>
    <machineKey validation="SHA1" validationKey="..." decryption="AES"
decryptionKey="..."/>

This gets anonymous profiles working okay and profile auto-saving also
works.

Here is my Global.asax file:

<%@Application Language="C#"%>
<Script RunAt="server">
  void Profile_MigrateAnonymous(Object sender, ProfileMigrateEventArgs e) {
    ProfileBase anonymous = ProfileBase.Create(e.AnonymousID, false);
    ProfileBase user = ProfileBase.Create(e.Context.User.Identity.Name,
true);
    if ((anonymous != null) && (user != null)) {
      string colour = (string)(anonymous.GetPropertyValue("Colour"));
      if (!String.IsNullOrEmpty(colour)) {
        user.SetPropertyValue("Colour", colour);
      }
    }
    ProfileManager.DeleteProfile(e.AnonymousID);
    AnonymousIdentificationModule.ClearAnonymousIdentifier();
    Membership.DeleteUser(e.AnonymousID, true);
  }
</Script>

The Global.asax file compiles okay but the Profile_MigrateAnonymous()
function is apparently NOT called when I log in as an authenticated user.

Does anybody know if this is supported and, if so, how can I get it to work
???
-- 
View this message in context: http://www.nabble.com/Profile_MigrateAnonymous%28%29-event-in-Global.asax-tp24872437p24872437.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.



More information about the Mono-aspnet-list mailing list