asp.net-mvc - MVC 中的区域与文件夹

标签 asp.net-mvc asp.net-mvc-5

我不涉及 MVC 中的区域,为什么我们不能有简单的文件夹来指示模块,是需要在那里的 web.config,下面是我问这个的原因

View - 不幸的是, View 是不可能的。所有 View 必须放在“~/Views/ControllerName”或“~/Views/Shared”文件夹中。

最佳答案

下面的文章详细介绍了Areas的产生原因以及Areas和ASP.NET MVC中基于文件夹的约定的区别。

http://www.codeguru.com/csharp/.net/net_asp/mvc/article.php/c20227/Using-Areas-in-ASPNET-MVC-Application.htm

文章的Introduction中包含了本质思想:

ASP.NET MVC relies on certain folder and class naming conventions to organize models, views and controllers. A large application often consists of functionally independent modules with the result that the main application is essentially a bundle of these sub-applications. In such cases, organizing various models, views and controllers can be tedious. Luckily, ASP.NET MVC allows you to split your application into what is known as Areas. Each area mimics the folder structure and conventions as required by ASP.NET MVC. This article shows you how Areas are used in an ASP.NET MVC application.

当有人试图开发适合包含在任何 ASP.NET MVC 应用程序中的子模块时(例如,考虑通过 NUGET 包部署/包含第 3 方代码),那么区域构造非常有用,并且可以说是必要的。

关于asp.net-mvc - MVC 中的区域与文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33047583/

相关文章:

asp.net-mvc - 使用 Asp.net Mvc 的缩略图

c# - IIS 7 错误 : Cannot execute a program. 正在执行的命令是 csc.exe(ApplicationPoolIdentity 默认设置)

javascript - jQuery 事件触发一次,然后再也不会

c# - 使用 Razor 的 ASP.net MVC 5 ViewBag

c# - Entity Framework 数据注释对 DDD 和关注点分离有害吗?

javascript - 如何动态添加行到html表

asp.net-mvc - MVC 客户端验证执行数据库检查

c# - jqGrid subGridRowExpanded 功能无法正常工作

vb.net - Visual Studio 2013 - VB.NET MVC 5 模板

c# - PrepareRequestUserAuthorizationAsync 失败