I\'m having this problem: No service for type \'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory\' has been registered. In asp.net core 1.0,
For .NET Core 2.0, in ConfigureServices, use :
services.AddNodeServices();
This one works for my case :
services.AddMvcCore()
.AddApiExplorer();
Right now i has same problem, I was using AddMcvCore like you. I found error self descriptive, as an assumption I added AddControllersWithViews service to ConfigureServices function and it fixed problem for me. (I still use AddMvcCore as well.)
public void ConfigureServices(IServiceCollection services)
{
//...
services.AddControllers();
services.AddControllersWithViews();
services.AddMvcCore();
//...
}
Just add following code and it should work:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvcCore()
.AddViews();
}
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();
});
}
}
You use this in startup.cs
services.AddSingleton<PartialViewResultExecutor>();