當前每當我嘗試使用默認成員身份服務註冊用戶或登錄時,我的主機提供商DiscountASP I上的ASP.Net MVC4收到錯誤要調用此方法,「Membership.Provider」屬性必須是「ExtendedMembershipProvider」的實例
To call this method, the "Membership.Provider" property must be an instance of "ExtendedMembershipProvider".
這不會發生在本地。
這是我InitializeSimpleMembershipAttribute.cs
:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public sealed class InitializeSimpleMembershipAttribute : ActionFilterAttribute
{
private static SimpleMembershipInitializer _initializer;
private static object _initializerLock = new object();
private static bool _isInitialized;
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// Ensure ASP.NET Simple Membership is initialized only once per app start
LazyInitializer.EnsureInitialized(ref _initializer, ref _isInitialized, ref _initializerLock);
}
private abstract class SimpleMembershipInitializer
{
protected SimpleMembershipInitializer()
{
Database.SetInitializer<UsersContext>(null);
try
{
using (var context = new UsersContext())
{
if (!context.Database.Exists())
{
// Create the SimpleMembership database without Entity Framework migration schema
((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
}
}
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
}
catch (Exception ex)
{
throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
}
}
}
}
以下是錯誤的全屏截圖:
有誰知道我怎麼能解決這個問題或知道解決它的文章?
,你能否告訴'' web.config中的一部分?看起來你試圖使用SimpleMembership,但提供者不匹配。另外,確保'WebMatrix。*'在參考'屬性下設置爲'Copy Local = True'。 –
我實際上沒有在我的Web.config中出於某種原因定義的成員資格部分。你能讓我知道它應該是什麼樣子嗎? –