Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

ASP.Net profile providers

Options
  • 08-09-2008 10:28pm
    #1
    Registered Users Posts: 5,238 ✭✭✭


    Kind of leading on from a previous thread I started here a good while back.

    I've implemented a custom profile provider and all the abstract methods.

    I've then added it to the web config file and was expecting to be able to type Profile.PropertyName and assign it a value but when I type Profile they don't show up. Tried everything I can think of but can't get it to work.

    Can anyone offer any suggestions.


    Here's my web.config, in case there is anything obviously wrong.
      <system.web>
        <pages>
          <controls>
            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          </controls>
          <namespaces>
          <clear/>
          <add namespace="System"/>
          <add namespace="System.Collections"/>
          <add namespace="System.Collections.Generic"/>
          <add namespace="System.Collections.Specialized"/>
          <add namespace="System.Configuration"/>
          <add namespace="System.Text"/>
          <add namespace="System.Text.RegularExpressions"/>
          <add namespace="System.Web"/>
          <add namespace="System.Web.Caching"/>
          <add namespace="System.Web.SessionState"/>
          <add namespace="System.Web.Security"/>
          <add namespace="System.Web.Profile"/>
          <add namespace="System.Web.UI"/>
          <add namespace="System.Web.UI.WebControls"/>
          <add namespace="System.Web.UI.WebControls.WebParts"/>
          <add namespace="System.Web.UI.HtmlControls"/>
          </namespaces>
        </pages>
    
        <compilation debug="true">
          <assemblies>
            <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          </assemblies>
        </compilation>
    
        <roleManager defaultProvider="SqlProvider"
            enabled="true"
            cacheRolesInCookie="true"
            cookieName=".ASPROLES"
            cookieTimeout="30"
            cookiePath="/"
            cookieRequireSSL="false"
            cookieSlidingExpiration="true"
            cookieProtection="All"  >
          <providers>
            <add
              name="SqlProvider"
              type="System.Web.Security.SqlRoleProvider"
              connectionStringName="SiteUserDB"
              applicationName="/" />
          </providers>
        </roleManager>
    
        <membership>
          <providers>
            <remove name="AspNetSqlMembershipProvider"/>
            <add name="AspNetSqlMembershipProvider"
                 type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                 connectionStringName="SiteUserDB"
                 enablePasswordRetrieval="false"
                 enablePasswordReset="true"
                 requiresQuestionAndAnswer="false"
                 applicationName="/"
                 requiresUniqueEmail="false"
                 passwordFormat="Hashed"
                 maxInvalidPasswordAttempts="5"
                 minRequiredPasswordLength="1"
                 minRequiredNonalphanumericCharacters="0"
                 passwordAttemptWindow="10"
                 passwordStrengthRegularExpression="" />
          </providers>
        </membership>
    
        <profile defaultProvider="UserProfileProvider" enabled =" true">
          <providers>
            <add
                  name="UserProfileProvider"
                  type="ProfileProvider.CustomProvider.Provider"
                  connectionStringName="SiteUserDB"
                  applicationName="/"
                                />
          </providers>
          <properties>
            <add name="Property1" type="System.String" allowAnonymous="true"/>
            <add name="Property2" type="System.String" allowAnonymous="true"/>
            <add name="Property3" type="System.Double" allowAnonymous="true"/>
          </properties>
        </profile>
        
        
      </system.web>
    


Comments

  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    Just off the top of my head, I think you would access them through a property on the Profile object, something like Profile.Properties["Property1"]. I suspect your Profile object is the base profile provider class, if you want to work with autocomplete you will need to define an object of your providers type and parse the Profile object into it

    UserProfileProvider myProfileObj = (UserProfileProvider) Profile;
    myProfileObj.Property1 = ... etc



    That's just off the top of my head though, I'm probably very wrong


Advertisement