aspnet mvc 使用什么模式?
我总是使用带有 MVP 模式的 asp.net webforms,它非常适合我的需要,我基本上创建了一个项目,其中包含我的所有业务规则、验证等...然后我在 webforms 项目中实现我的视图。
现在我们开始使用 asp.net MVC,使用 MVP 模式没有多大意义,对吧?那么,使用 MVC 创建可扩展且可测试的项目的好方法是什么,它不会让我创建数据对象并在控制器上进行验证。我不想在不同的地方使用相同的代码...
如果网络用户想要更新他/她在网站上的个人资料,当按下提交按钮时会有一些验证规则,例如电子邮件地址不能为空,必须有效且不得存在于数据库中。
如果我尝试使用内部管理部分更新他的个人资料,而不必在那里复制代码,则应该应用这些相同的规则...
如果您能给我指出一个处理此问题的良好示例项目,那就太好了!
提前致谢!
I always used asp.net webforms with the MVP pattern, it works great for what I need, I basically create a project where all my business rules reside, validation etc... and I then implement my views in the webforms project.
Now we're starting to use asp.net MVC and using the MVP patter doesn't make much sense, right? So what could be a good approach to create a scalable and testable project using MVC that won't make me create my data objects and do validation on the controllers. I don' want to have the same code in different places...
If a web user wants to update his/her profile on the site, there would be some validation rules for when a submit button is pushed, like email address cannot be empty, must be valid and must not exist in the database.
These same rules should be applied if I try to update his profile using the internal admin section without having to duplicate the code there...
If you can point me to a good sample project that deals with this would be great!
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该将 MVC 模式与 ASP.Net MVC 结合使用。
You should use the MVC pattern with ASP.Net MVC.
NerdDinner 教程是一个非常详细的 MVC 示例,您还可以获得 图书,其中包括教程(您可能需要等待涵盖 ASP.Net MVC 3)。 Microsoft 的 ASP.Net 站点上有大量资源。
您可以随时咨询 Google。
The NerdDinner tutorial is a pretty detailed example for MVC, you can also get a book that includes the tutorial (you might want to wait for the version that covers ASP.Net MVC 3). There are plenty of resources on Microsoft's ASP.Net site.
You can always consult Google.
ASP .NET MVC 是使用 模型-视图-控制器构建的(MVC) 记住的模式。这将是您想要使用的模式。
除了 magnifico 提供的资源之外,我知道其他人还推荐了其他一些教程。我不知道这些是否已更新到最新版本的框架,但它们仍然应该作为不错的初学者。
MVC Storefront 系列
MVC 音乐商店
还有 Microsoft Patterns 和 Microsoft Patterns。实践小组最近发布了 Project Silk,它采用了更先进的技术,涉及大量的 UI AJAX 管理。那里有有趣的东西。
ASP .NET MVC was built with the Model-View-Controller (MVC) pattern in mind. That would be the pattern you'd want to use.
In addition to the resources magnifico provided, I know others have recommended the some other tutorials. I don't know if these have been updated to the latest version of the framework, but they should still serve as decent beginners.
MVC Storefront series
MVC Music Store
Also the Microsoft Patterns & Practices group recently released Project Silk which gets into more advanced techniques involving a lot of AJAX management of the UI. There's interesting stuff there.