Criei um web site. asp.net C#
Adicionei no meu web config dessa forma
<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>
Quando vou criar um usuário crio também o meu perfil dessa forma:
//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();
Até aí tudo bem. Quando vou logar pego o ProfileCommon assim:
ProfileCommon profile = Profile.GetProfile(Login.Text);
Quando sou redirecionado para outra página, tento pegar uma propriedade do meu perfil dessa forma. Profile.TipoPermissao
porem o Profile vem vazio, alguém pode me ajudar?