Ich habe dieses Problem: Kein Dienst für den Typ 'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory' wurde registriert. In asp.net Core 1.0 scheint es, dass wenn die Aktion versucht, die Ansicht zu rendern, ich diese Ausnahme habe.Kein Dienst für den Typ 'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory' wurde registriert
Ich habe viel gesucht, aber ich habe keine Lösung gefunden, wenn mir jemand helfen kann, herauszufinden, was passiert und wie ich es beheben kann, werde ich es zu schätzen wissen.
Mein Code unten:
Meine project.json Datei
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-rc1-final"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dnxcore50",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
Meine Startup.cs Datei
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OdeToFood.Services;
namespace OdeToFood
{
public class Startup
{
public IConfiguration configuration { get; set; }
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IRestaurantData, InMemoryRestaurantData>();
services.AddMvcCore();
services.AddSingleton(provider => configuration);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
//app.UseRuntimeInfoPage();
app.UseFileServer();
app.UseMvc(ConfigureRoutes);
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!");
});
}
private void ConfigureRoutes(IRouteBuilder routeBuilder)
{
routeBuilder.MapRoute("Default", "{controller=Home}/{action=Index}/{id?}");
}
}
}
Ist es mit einer bestimmten Seite passiert? Was versuchst du auf dieser Seite zu tun? Auch wenn Sie die Registrierung von IRestaurantData auskommentieren, konnten Sie das Problem replizieren? – Shyju
@Shyju, danke für die Wiederholung, es passiert gerade, wenn ich versuche, die View() -Methode aufzurufen, um eine Ansicht in einer Aktion von meinem HomeController anzuzeigen, immer sogar ich nicht überladen die Methode Es immer die Ausnahme werfen, auch wenn ich kommentiere der 'IRestanData' Registrierungsservice das Problem immer noch passiert, ist dieses Problem so komisch :(Weil es scheint, dass ich etwas Namensraum oder etwas vermisse, aber die vs zeigen mir nichts falsch im Code –
@Shyju das sind die Namespace i mit ‚m: ' Microsoft.AspNetCore.Mvc verwendet; '' mit OdeToFood.ViewModels; '' mit OdeToFood.Services; '' OdeToFood.Entities verwendet; ' –