我正在研究MVC 4应用程序。当用户进行身份验证时,我必须在所有页面上显示图片配置文件。
我尝试使用此处的代码:.net profile provider and custom profiles. The settings property '' was not found.来实现Profile属性。但我收到了一个错误!
我的个人资料类:
using System.Web.Profile;
using System.Web.Security;
namespace Toombu
{
public class ProfileCommon : ProfileBase
{
public static ProfileCommon GetUserProfile(string username)
{
return Create(username) as ProfileCommon;
}
public static ProfileCommon GetUserProfile()
{
var membershipUser = Membership.GetUser();
return Create(membershipUser.UserName) as ProfileCommon;
}
[SettingsAllowAnonymous(false)]
public string Picture
{
get
{
return base["Picture"] as string;
}
set
{
base["Picture"] = value;
}
}
}
}
这是我的Webconfig文件,我想我在这里犯了一个错误,但我不知道在哪里。
<profile inherits="Toombu.ProfileCommon">
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ToombuContext"/>
</providers>
</profile>
我使用的是sqlServer数据库。我的连接字符串:
<add name="ToombuContext" connectionString="Data Source=.;Initial Catalog=toombu;Integrated Security=SSPI;;Persist Security Info=True;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
我的观点:
@if (Request.IsAuthenticated)
{
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img style="width: 20px;-webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px;" src="@ProfileCommon.GetUserProfile().Picture" />
</a>
}
我收到了这个错误:
Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'
我该怎么办?