Поставщик профиля на самом деле немного отличается от поставщика роли и членства.Обычно вы задаете ключи профиля в конфигурации, такие как ..
..
<profile enabled="true"
defaultProvider="CustomProfileProvider">
<providers>
<clear />
<add
name="CustomProfileProvider"
type="Providers.CustomProfileProvider, Providers"
ApplicationName="Test" />
</providers>
<properties>
<add name="ZipCode" allowAnonymous="false" />
<add name="Phone" allowAnonymous="false" />
</properties>
Все, что вам нужно сделать, это реализовать абстрактный класс и установить его так, чтобы он былиспользуется в web.config.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Profile;
namespace blahh.Web.Source
{
class Class1 : ProfileProvider
{
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
throw new NotImplementedException();
}
public override int DeleteProfiles(string[] usernames)
{
throw new NotImplementedException();
}
public override int DeleteProfiles(ProfileInfoCollection profiles)
{
throw new NotImplementedException();
}
public override ProfileInfoCollection FindInactiveProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override ProfileInfoCollection FindProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override ProfileInfoCollection GetAllInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override int GetNumberOfInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
throw new NotImplementedException();
}
public override string ApplicationName
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public override System.Configuration.SettingsPropertyValueCollection GetPropertyValues(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyCollection collection)
{
throw new NotImplementedException();
}
public override void SetPropertyValues(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyValueCollection collection)
{
throw new NotImplementedException();
}
}
}
http://www.davidhayden.com/blog/dave/archive/2007/10/30/CreateCustomProfileProviderASPNET2UsingLINQToSQL.aspx имеет большое руководство по поставщику профилей generif.
Также вы можете взглянуть на источник коннектора mysql для.нет, так как у него есть собственный провайдер.
Существует также http://www.codeproject.com/KB/aspnet/AspNetEFProviders.aspx?display=Print
Итак, в двух словах, провайдер профиля - единственный, кого вы не делаете, как провайдеры членства и роли.