小编OMI*_*MID的帖子

尝试激活'AuthController'时无法解析类型'Microsoft.AspNetCore.Identity.UserManager`的服务

我在登录控制器中收到此错误.

InvalidOperationException:尝试激活'Automobile.Server.Controllers.AuthController'时,无法解析类型'Microsoft.AspNetCore.Identity.UserManager`1 [Automobile.Models.Account]'的服务.

这是Auth Controller构造函数:

private SignInManager<Automobile.Models.Account> _signManager;
    private UserManager<Automobile.Models.Account> _userManager;

    public AuthController(UserManager<Models.Account> userManager,
                          SignInManager<Automobile.Models.Account> signManager)
    {
        this._userManager = userManager;
        this._signManager = signManager;
    }
Run Code Online (Sandbox Code Playgroud)

这是在startup.cs中的ConfigureServices:

public void ConfigureServices(IServiceCollection services)
    {
        // Add framework services.
        services.AddApplicationInsightsTelemetry(Configuration);
        services.Configure<AppConfig>(Configuration.GetSection("AppSettings"));

        //var provider = HttpContext.ApplicationServices;
        //var someService = provider.GetService(typeof(ISomeService));


        services.AddDbContext<Providers.Database.EFProvider.DataContext>(options => options
            .UseSqlServer(Configuration.GetConnectionString("DefaultConnection"),
                 b => b.MigrationsAssembly("Automobile.Server")
            ));


        services.AddIdentity<IdentityUser, IdentityRole>(options =>
        {
            options.User.RequireUniqueEmail = false;
        })
        .AddEntityFrameworkStores<Providers.Database.EFProvider.DataContext>()
        .AddDefaultTokenProviders(); 
        //services.AddScoped<SignInManager<Automobile.Models.Account>, SignInManager<Automobile.Models.Account>>();
        //services.AddScoped<UserManager<Automobile.Models.Account>, UserManager<Automobile.Models.Account>>();

        services.AddMvc();
        App.Service = services.BuildServiceProvider();

        // Adds a default in-memory implementation of IDistributedCache.
        services.AddDistributedMemoryCache();

        services.AddSession(options …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc asp.net-core asp.net-core-identity

63
推荐指数
5
解决办法
5万
查看次数

Team Foundation Error,页面'3185ed96-1cbd-4381-a439-636973542e50'未找到

我开始使用Visual Studio 2015 Enterprise,当我想使用Team Foundation Server管理连接或其他任何内容时,会出现此错误:Team Foundation Error,Page'3185991-1cbd-4381-a439-636973542e50'找不到.我该怎么办?!

还有一件事......我看到了这个但不适合我: 在Visual Studio 2012中找不到页面

tfs tfsbuild visual-studio visual-studio-2015

8
推荐指数
1
解决办法
9409
查看次数

ASP.NET Core发布错误:启动应用程序时发生错误

我试图在Windows Server 2008 R2上发布我的ASP.NET核心应用程序,但是我收到此错误:"启动应用程序时出错."

没有更多的描述!

我能做什么?

asp.net asp.net-core-mvc asp.net-core visual-studio-2017 asp.net-core-1.1

4
推荐指数
2
解决办法
5978
查看次数

在Asp.net核心身份中通过电话号码注册和登录

是否有可能不使用电子邮件注册并登录asp.net核心身份?

用户只需通过手机号码注册并通过短信验证登录.

asp.net-mvc asp.net-identity asp.net-core asp.net-core-identity

4
推荐指数
1
解决办法
2481
查看次数