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

前端 未结 11 821
终归单人心
终归单人心 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:26

    If you're using 2.x then use services.AddMvcCore().AddRazorViewEngine(); in your ConfigureServices

    Also remember to add .AddAuthorization() if you're using Authorize attribute, otherwise it won't work.

    Update: for 3.1 onwards use services.AddControllersWithViews();

提交回复
热议问题