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

前端 未结 11 790
终归单人心
终归单人心 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条回答
  •  Happy的楠姐
    2021-01-01 09:28

    Solution: Use AddMvc() instead of AddMvcCore() in Startup.cs and it will work.

    Please see this issue for further information about why:

    For most users there will be no change, and you should continue to use AddMvc() and UseMvc(...) in your startup code.

    For the truly brave, there's now a configuration experience where you can start with a minimal MVC pipeline and add features to get a customized framework.

    https://github.com/aspnet/Mvc/issues/2872

    You might also have to add a reference toMicrosoft.AspNetCore.Mvc.ViewFeature in project.json

    https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.ViewFeatures/

提交回复
热议问题