I created a web site. Asp.net C #
I added in my web config this way
<authentication mode="Forms" >
<forms loginUrl="principal.aspx"
name=".ASPXFORMSAUTH" />
</authentication>
<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="labPuc"
applicationName="/" />
</providers>
</roleManager>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5"/>
<membership defaultProvider="SqlMembershipProvider">
<providers>
<clear/>
<add name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="labPuc" applicationName="/" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" minRequiredNonalphanumericCharacters="2" minRequiredPasswordLength="6" maxInvalidPasswordAttempts="3"/>
</providers>
</membership>
<profile defaultProvider="AspNetSqlProfileProvider">
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" applicationName="/" connectionStringName="labPuc"/>
</providers>
<properties>
<add name="UserId" type="System.String"/>
<add name="Email" type="System.String"/>
<add name="TipoPermissao" type="System.String"/>
<add name="Habilitado" type="System.String"/>
</properties>
</profile>
When I create a user I also create my profile this way:
//Provedor de perfil
ProfileCommon perfil = (ProfileCommon)ProfileCommon.Create(login.Text, true);
perfil.UserId = user.ProviderUserKey.ToString();
perfil.Email = user.Email;
perfil.Habilitado = "S";
perfil.TipoPermissao = "Administrador";
perfil.Save();
So far so good. When I log in I get ProfileCommon like this:
ProfileCommon profile = Profile.GetProfile(Login.Text);
When I'm redirected to another page, I try to pick up a property from my profile in this way. Profile.TipoPermissao
But the Profile is empty, can anyone help me?