ASP.NET核心异常"查找未找到"

时间:2017-03-05 18:27:24

标签: c# asp.net asp.net-core

我创建了一个包含多个应用程序的解决方案,我配置了这样的路由:

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "ControlPanel",
                template: "ControlPanel/{controller=Home}/{action=Index}/{id?}");

            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });

我可以导航到ControlPanel项目,它进入ihome控制器但是我显示了这个错误: enter image description here

我发现当项目第一次运行时它会在我的program.cs中设置基目录,它是我的主要webapplication程序集名称(CustomerProject):

enter image description here

所以现在如何将ContentDirectory和wwwroot目录更改为新的程序集名称?

1 个答案:

答案 0 :(得分:1)

我猜你去过URL有控制器名称而没有指定动作方法,或者它像yourhost/iHome/Index一样,所以你已经执行Index iHome控制器的动作了在您的解决方案中没有Index.cshtml。视图引擎无法找到您请求的特定页面,因此请尝试将Index.cshtml添加到/Views/iHome//Views/Shared/个文件夹中。 此外,我建议阅读this,以便了解视图发现的工作原理。