我不涉及 MVC 中的区域,为什么我们不能有简单的文件夹来指示模块,是需要在那里的 web.config,下面是我问这个的原因
View - 不幸的是, View 是不可能的。所有 View 必须放在“~/Views/ControllerName”或“~/Views/Shared”文件夹中。
最佳答案
下面的文章详细介绍了Areas的产生原因以及Areas和ASP.NET MVC中基于文件夹的约定的区别。
文章的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/