小编Moh*_*ood的帖子

没有类型“Microsoft.AspNetCore.Identity.UserManager”的服务:在尝试扩展 IdentityUser 时?

我在 mac 机器上使用 asp.net 核心,我试图为我的 asp.net mvc web 应用程序创建一个自定义的 ApplicationUser,它与基本 IdentityUser 一起工作得非常好。

尽管遵循 Microsoft 的本指南:

https://docs.microsoft.com/en-us/aspnet/core/security/authentication/add-user-data?view=aspnetcore-2.1&tabs=visual-studio

我面临这个错误:

{"error":"没有注册'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]'类型的服务。"}

以下是我的代码片段:

启动文件

    public void ConfigureServices(IServiceCollection services)
    {
        services.Configure<CookiePolicyOptions>(options =>
        {

        // [...]

        services.AddDbContext<ApplicationDbContext>(
            options => options.UseSqlServer(identityDbContextConnection));
        // Relevant part: influences the error
        services.AddIdentity<ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores<ApplicationDbContext>()
        .AddDefaultTokenProviders();


        services.AddMvc(config =>
        {
            var policy = new AuthorizationPolicyBuilder()
                             .RequireAuthenticatedUser()
                             .Build();
            config.Filters.Add(new AuthorizeFilter(policy));
        });
    }
Run Code Online (Sandbox Code Playgroud)

应用程序用户.cs

    // Add profile data for application users by adding properties to the ApplicationUser class
public class ApplicationUser : IdentityUser
{
    [Required] …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-core

7
推荐指数
2
解决办法
7908
查看次数

未捕获的类型错误:this.getExtraNgModuleProviders 不是函数

我正在处理一个不断在控制台上抛出此错误的存储库: Uncaught TypeError: this.getExtraNgModuleProviders is not a function.

这些项目在“ng serve”上编译得很好,但它在控制台上显示一个空白页面和那个错误。我尝试了很多事情,但我找不到出路。

我试过卸载和安装@angular/compiler,但没有用。问题似乎是 JitCompiler 没有找到this.getExtraNgModuleProviders

我认为this.getExtraNgModuleProvidersJitCompiler 中的函数应该this._getExtraNgModuleProviders在 compiler.js 上。因为它周围的所有功能似乎都包含下划线。

更新:

我不认为函数名称与它有任何关系,因为其他开发人员可以很好地运行该项目,并且他们拥有相同的 Jit compiler.js 文件。供参考:当我单击控制台上的错误时,这是​​我需要的地方

 function JitCompiler(_metadataResolver, _templateParser, _styleCompiler, _viewCompiler, _ngModuleCompiler, _summaryResolver, _reflector, _compilerConfig, _console, getExtraNgModuleProviders) {
            this._metadataResolver = _metadataResolver;
            this._templateParser = _templateParser;
            this._styleCompiler = _styleCompiler;
            this._viewCompiler = _viewCompiler;
            this._ngModuleCompiler = _ngModuleCompiler;
            this._summaryResolver = _summaryResolver;
            this._reflector = _reflector;
            this._compilerConfig = _compilerConfig;
            this._console = _console;
            this.getExtraNgModuleProviders = getExtraNgModuleProviders;//<- error is pointed here
            this._compiledTemplateCache = new Map();
            this._compiledHostTemplateCache = …
Run Code Online (Sandbox Code Playgroud)

javascript jit angular angular6 angular7

6
推荐指数
1
解决办法
2714
查看次数

标签 统计

angular ×1

angular6 ×1

angular7 ×1

asp.net ×1

asp.net-core ×1

c# ×1

javascript ×1

jit ×1