【发布时间】:2011-02-02 05:01:46
【问题描述】:
我很困惑必须在 MVC 1.0 项目结构中设置视图和相应的控制器。目前在默认应用程序中,我们在 Home 文件夹下有 About.aspx 页面,所有控制器操作都在 HomeController 中处理。这个控制器混合了 Home 动作和 About 动作。它使事情变得混乱。我喜欢清楚地分离我的控制器。喜欢分别拥有一个 About Controller 和 HomeCotroller。为此,我在视图文件夹下创建了另一个文件夹“About”并将 Aboput.aspx 放入其中,否则我们将收到以下错误。我怎样才能实现它?我喜欢在 View 中拥有与在 Cotroller 中一样的精确文件夹结构。
The view 'About' or its master could not be found. The following locations were searched:
~/Views/About/About.aspx
~/Views/About/About.ascx
~/Views/Shared/About.aspx
~/Views/Shared/About.ascx
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The view 'About' or its master could not be found. The following locations were searched:
~/Views/About/About.aspx
~/Views/About/About.ascx
~/Views/Shared/About.aspx
~/Views/Shared/About.ascx
我喜欢有像 \iew\About.aspx 和 Cotroller\AboutController.cs 这样的文件夹 或 \View\Info\About.aspx 和 \Controller\Info\AboutController.cs。
这将使我的项目和代码放置得非常干净且易于维护。 在此先感谢您的帮助
【问题讨论】:
标签: asp.net-mvc routing