이 문제가 발생했습니다. 'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory'유형의 서비스가 등록되지 않았습니다. asp.net 코어 1.0에서, 그 행동이보기를 렌더링하려고 할 때 그 예외가있는 것 같습니다.'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory'유형의 서비스가 등록되지 않았습니다.
나는 많은 것을 수색했으나, 누군가가 나에게 무슨 일이 일어나고 있는지 알아낼 수 있다면 어떻게 해결할 수 있을지, 나는 그것을 고맙게 생각한다.
내 코드를 넣고 :내 project.json 파일
{
"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%" ]
}
}
내 Startup.cs 파일
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?}");
}
}
}
특정 페이지로 이동하고 있습니까? 그 페이지에서 뭘 하려구? 또한 'IRestaurantData'의 등록을 주석 처리 할 때 문제를 복제 할 수 있습니까? – Shyju
@Shyju, 재생 주셔서 감사합니다, 그냥 내가 내 homeController의 행동에보기를 표시하기 위해 View() 메소드를 호출하려고 할 때 발생합니다. 항상 메소드를 오버로드하지 않습니다. 예외를 던지십시오. 'IRestaurantData' 등록 서비스 문제가 여전히 일어나고 있습니다. 그래서 이상한 일입니다. (왜냐하면 내가 네임 스페이스 orsomething을 놓치고있는 것처럼 보이기 때문입니다. 그러나 대요. 코드에서 아무 것도 보여주지 않습니다. –
@Shyju 이것은 네임 스페이스입니다. 'M using : 'Microsoft.AspNetCore.Mvc;를 사용하여 OdeToFood.ViewModels; –