9
我使用asp.net MVC 5與外部提供商owin提供(Facebook,Twitter的)ApplicationUserManager.Create稱爲在每次請求
ApplicationUserManager.Create被稱爲在每次請求。有很多不必要的東西用於登錄的用戶在那裏(密碼驗證配置或短信和電子郵件服務confguration ....)
var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
// Configure validation logic for usernames
manager.UserValidator = new UserValidator<ApplicationUser>(manager)
{
AllowOnlyAlphanumericUserNames = true,
RequireUniqueEmail = true
};
// Configure validation logic for passwords
manager.PasswordValidator = new PasswordValidator
{
RequiredLength = 7,
RequireNonLetterOrDigit = false,
RequireDigit = true,
RequireLowercase = true,
RequireUppercase = true,
};
...
而且,我認爲它是與此
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
// Configure the db context, user manager and signin manager to use a single instance per request
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
...
我可以做些什麼來讓這個「創建」僅在需要時調用。我不想實例密碼驗證和其他的東西在那裏當不需要
謝謝
你有沒有找到原因?我也正在處理這個問題。 – prospector