Hiện tại bất cứ khi nào tôi cố gắng đăng ký người dùng hoặc đăng nhập bằng dịch vụ thành viên mặc định được tích hợp vào ASP.Net MVC4 trên nhà cung cấp máy chủ của tôi DiscountASP I nhận được lỗiĐể gọi phương thức này, thuộc tính "Membership.Provider" phải là phiên bản của "ExtendedMembershipProvider"
To call this method, the "Membership.Provider" property must be an instance of "ExtendedMembershipProvider".
Điều này không xảy ra tại địa phương.
Đây là tôi 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);
}
}
}
}
Đây là một ảnh chụp màn hình đầy đủ của lỗi:
Có ai biết làm thế nào tôi có thể sửa lỗi này hoặc biết một bài viết mà giải quyết nó?
Bạn có thể hiển thị '' phần web.config? Có vẻ như bạn đang cố gắng sử dụng SimpleMembership nhưng nhà cung cấp không phù hợp. Ngoài ra, hãy chắc chắn 'WebMatrix. *' Được đặt thành 'Sao chép địa phương = True' trong thuộc tính 'tham chiếu'. –
Tôi thực sự không có một phần thành viên được xác định trong Web.config của tôi vì một lý do nào đó. Bạn có thể cho tôi biết nó sẽ trông như thế nào không? –