【问题标题】:The view 'Index' or its master could not be found找不到视图“索引”或其主视图
【发布时间】:2011-02-24 21:45:54
【问题描述】:

今天我开始使用区域重组我的 mvc 项目。所以我有一些问题。 我创建区域、移动视图和母版页、进行路由,但是当我尝试查看任何区域页面时,我得到“无法找到视图'登录'或其主页面。”

有什么建议吗?我google了一段时间,没有找到任何解决方案。

我的 global.asax 路由:

routes.MapRoute("Areaname", "Areaname",
                            "Areaname/{controller}/{action}/{id}",
                            new { controller = "controllerName", action = "Home", id = UrlParameter.Optional },
                            new string[] { "path.to.area.controllers.Controllers" });

区域注册路由:

public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Areaname_default",
                "Areaname/{controller}/{action}/{id}",
                new { action = "Home", id = UrlParameter.Optional },
                new string[] { "path.to.area.controllers.Controllers" }
            );
        }

似乎是正确的,但视图仍然不可用。

提前致谢。

【问题讨论】:

  • 某事告诉我您通过登录重定向触发进行了身份验证(由于 web.config 中的设置)。该路径是否也符合新设计?
  • 我的应用中没有任何身份验证

标签: c# asp.net-mvc view asp.net-mvc-routing


【解决方案1】:

使用区域时,请确保您像这样重写您的操作链接:

 Html.ActionLink("Invoicing link", "Index", "CustomerInvoices", new { area = "Invoicing" }, null)

在本例中,您将链接到“Invoicing”区域内的“CustomerInvoices”控制器内的“Index”操作。

确保您进行了适当的修改以链接到您区域内的登录操作!

【讨论】:

    猜你喜欢
    • 2016-04-10
    • 2011-01-17
    • 2020-06-29
    • 2013-06-23
    • 2013-08-18
    • 2012-04-29
    • 1970-01-01
    • 2015-07-09
    相关资源
    最近更新 更多