视图“索引”或者找不到它的主人

发布于 2024-10-19 06:13:02 字数 938 浏览 5 评论 0原文

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

有什么建议吗?我用谷歌搜索了一段时间,但没有找到任何解决方案。

我的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" }
            );
        }

看起来是正确的,但是视图仍然不可用。

提前致谢。

Today I've started restructuring my mvc project using areas. So I have some problems with it.
I make areas, move views and master pages, make routing, but when I'm trying to view any area page I get "The view 'Login' or its master could not be found."

Any suggestions? I've googled for some time, but didn't found any solution.

My global.asax routing:

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

Area registration routing:

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" }
            );
        }

It seems to be correct, but views are still unavailable.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感受沵的脚步 2024-10-26 06:13:02

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

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

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

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

When using Areas, make sure you rewrite your action links like this:

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

In this example, you are linking to the "Index" action, inside "CustomerInvoices" controller, inside "Invoicing" Area.

Make sure you do the proper modifications to link to the Login action inside your Area!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文