mysqlprofileprovider无法连接

时间:2016-05-25 14:47:37

标签: c# mysql asp.net mysql-connector

你好我用Google搜索了,但不幸的是找不到任何解决方案。

我已经设置了我的mysqlprovider:

public class UserProfile : ProfileBase
{
    [SettingsAllowAnonymous(false)]
    public string FirstName
    {
        get { return base["FirstName"] as string; }
        set { base["FirstName"] = value; }
    }

    [SettingsAllowAnonymous(false)]
    public string LastName
    {
        get { return base["LastName"] as string; }
        set { base["LastName"] = value; }
    }

    [SettingsAllowAnonymous(false)]
    public String test { get; set; }

    public static UserProfile GetUserProfile(string username)
    {
        return Create(username) as UserProfile;
    }

    public static UserProfile GetUserProfile()
    {
        return Create(Membership.GetUser().UserName) as UserProfile;
    }
}

web.config部分:

<connectionStrings>
    <add name="MySQLServer" connectionString="Pooling=false;data source=xxx;Persist Security Info=false;database=xx;user id=xx;password=xx;Pooling=false" providerName="MySql.Data.MySqlClient" />
</connectionStrings>

<profile inherits="SA2.Infrastructure.BO.Security.UserProfile" defaultProvider="MySQLProfileProvider">
  <providers>
    <clear />
    <add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" /></providers>
</profile>

我正在尝试创建一个类似的配置文件:

UserProfile lProfile = (UserProfile)SA2.Infrastructure.BO.Security.UserProfile.Create(User.Identity.Name);
lProfile.test = "Wurstsalat";
lProfile.Save();

似乎根本没有连接到数据库。我没有得到例外或反对。我有点迷失在这里......

0 个答案:

没有答案