No service for type 'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory' has been registered

前端 未结 11 784
终归单人心
终归单人心 2021-01-01 08:57

I\'m having this problem: No service for type \'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory\' has been registered. In asp.net core 1.0,

11条回答
  •  轮回少年
    2021-01-01 09:15

    I know this is an old post but it was my top Google result when running into this after migrating an MVC project to .NET Core 3.0. Making my Startup.cs look like this fixed it for me:

    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
        }
    
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
    
            app.UseRouting();
    
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
    }
    

提交回复
热议问题