在开发环境中启动时登录帐户

时间:2017-03-01 19:35:25

标签: asp.net-core asp.net-identity-2

在ASP.Net Core中,如何使用Identity在开发环境中启动时登录帐户?

我试图通过ServiceProvider在Configure函数中获取SignInManager。

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    if (env.IsDevelopment())
    {
        using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())
        {
            var signInManager = serviceScope.ServiceProvider.GetService<SignInManager<ApplicationUser>>();
            signInManager.PasswordSignInAsync("user", "password", true, lockoutOnFailure: false).Wait();
        }
...

但是dotnet在PasswordSignInAsync调用时崩溃了。

0 个答案:

没有答案