创建可重用的“基本代码”使用MVC2-RC?
我正在尝试为 MVC2 项目编写一个简单的库,负责用户登录、电子邮件验证、密码恢复等。由于其中一些步骤涉及用户交互,因此我需要在该项目中拥有视图和控制器。
在 MVC2 Preview 2 中,人们可以通过滥用区域来做到这一点(至少看起来如此),因为它们是在不同的项目中实现的。然而,在 RC 中,新区域只会创建一个子文件夹。由于我想在应用程序之间共享基本代码,因此这不是一个选择。
我试图粗暴地将 AfterBuild 步骤侵入到我的项目文件中,但这“感觉不对”(我又睡不着觉了:)
你能分享一些关于如何做到这一点的想法吗?
I am trying to write a simple library for MVC2 projects that takes care of user login, e-mail validation, password recovery, etc. Since some of these steps involve user interaction, I need to have Views and Controllers in that project.
In MVC2 Preview 2, one could do this by abusing areas (at least, it seems) since they were implemented in different projects. However, in RC a new area will merely create a subfolder. Since I want to share the base code between applications, that is not an option.
I tried to brutally hack the AfterBuild steps into my project files, but that doesn't 'feel right' (I wouldn't sleep another night :)
Could you share some thoughts on how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此问题可能与 多个项目的区域重复 -在子项目中找不到视图
复制视图的构建任务已移至
Mvc.Futures
项目。解决该问题的其他选项包括在应用程序中定义视图,即使库中的控制器正在引用它们。此外,MvcContrib 项目还提供可移植区域。Phil Haack 的详细解释可以在 http://forums.asp.net/ 找到p/1494640/3540105.aspx
This question might be a duplicate of Areas over multiple projects - Views not found in child projects
The build task to copy the views have been moved to the
Mvc.Futures
project. Other options to solve the problem include defining the views in the application, even when they are being referred to by controllers in the library. Also, the MvcContrib project offers portable areas.A thorough explanation by Phil Haack can be found at http://forums.asp.net/p/1494640/3540105.aspx