如何组织这个 ASP.NET MVC2 项目?

发布于 2024-10-06 13:51:58 字数 530 浏览 2 评论 0原文

我的任务是创建一个类似门户的应用程序,该应用程序将托管许多小型应用程序。这是我第一次涉足 MVC,我很难确定如何最好地组织项目来处理逻辑路由。

路由模式是:
{app}/{activity}/{controller}/{action}

示例:
订购系统/订购/当前订单/查看
管理员/安全/用户/编辑
EducationSystem/EducationPlans/CurrentPlan/View

Areas 似乎是 {app} 级别路由的合理选择,但从外观上看,它们不能嵌套。我是否就让我的区域控制器成为 {activities} + {controllers} 的无序混合体?

如果这就是答案,我该如何处理路由?我不希望我的路由表映射太细粒度,但如果活动概念要与控制器概念共享空间,我不认为这是可以避免的。

或者,我是否需要考虑单独托管这些应用程序?对于这个项目来说,这当然是一个可行的选择,但仅仅处理额外的逻辑分离层似乎会带来很多麻烦。

MVCContrib 或其他第三方库中有什么可以提供帮助的吗?

I'm tasked with creating a portal-like application that will host a number of small apps. This is my first venture into MVC, and I'm having difficulty determining how best to organize the project to handle the logical routing.

The routing pattern is:
{app}/{activity}/{controller}/{action}

Examples:
OrderingSystem/Ordering/CurrentOrders/View
Admin/Security/Users/Edit
EducationSystem/EducationPlans/CurrentPlan/View

Areas seem like a logical choice for the {app} level of routing, but from the look of things, they can't be nested. Do I just let my area controllers be a disorderly mixture of {activities} + {controllers}?

If that's the answer, how do I handle the routing? I'd prefer not to have my routing table mappings be too finely grained, but if the activity concept is going to share space with the controller concept I don't see how this is avoidable.

Alternatively, do I need to consider hosting these apps separately? That's certainly a viable option for this project, but it seems like an awful lot of trouble just to handle an extra layer of logical separation.

Anything in MVCContrib or other third party libraries that could help?

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

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

发布评论

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

评论(1

梦在深巷 2024-10-13 13:51:58

我自己解决了这个问题,所以我想我应该与社区分享解决方案。

简而言之,ASP.NET MVC 2 框架支持嵌套区域,但 Visual Studio 2010 提供的工具不支持嵌套区域。只要您遵守文件结构约定并创建一个 AreaRegistration 派生类来处理路由,MVC 2 将非常乐意向世界提供您的观点。问题是 - 您必须手动创建所有基础设施。

给我一些时间,我将发布一些示例代码。

I figured this one out on my own, so I thought I'd share the solution with the community.

The short answer is, nested areas are supported/supportable by the ASP.NET MVC 2 framework, but not by the tools provided with Visual Studio 2010. As long as you are conforming to the file structure conventions and creating a AreaRegistration-derived class to handle the routing, MVC 2 will be perfectly happy to serve your views to the world. The catch is - you'll have to manually create all the infrastructure.

Give me some time, and I'll post some example code.

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