MVC3网站结构帮助
我正在使用 MVC3、EF 和 Razor 构建一个网站,目前该网站的前端大部分工作正常。它是一个包含产品、用户等的“商店”,在前端您可以浏览产品、查看用户的评分并购买产品。
现在,我正在考虑后端,从目前为止所掌握的情况来看,后端在很多方面似乎都是多余的。我想要一个完整的后端区域来管理所有产品、用户、销售等(最好是/Admin/Controller/Action,但如果我想要在后端有一个页面列出所有产品,这将与列出所有产品的前端控制器相同(至少从控制器的角度来看)
我的问题是,有什么好的方法可以解决这个问题,到目前为止我是完全错误的还是我。在正确的轨道上,只需要一些调整。还阅读了有关 Areas 的内容,但找不到任何与 MVC3 一起使用的好文档。我应该在后端重复功能还是有更好的方法?感谢您的帮助!
I'm building a website using MVC3, EF, and Razor and I currently have the front-end of the site mostly working. It's a "store" of sorts with products, users, etc and in the front end you can browse for products, see ratings by users, and purchase the products.
Now, I am thinking about the back-end and from what I have so far, it seems like hte back-end will be redundant in a lot of ways. I would like to have an entire back-end area to manage all the products, users, sales, etc (preferably /Admin/Controller/Action, but if I want a page in the back-end that lists all of the products, this is going to be identical (at least from the controller standpoint) to the front-end controller that lists all of the products.
My question is, what are some good ways to go about this, am i completely wrong so far, or am I on the right track and just need some tweaking. I have also read about Areas, but have been unable to find any good documentation to use with MVC3. Should i duplicate functionality in the back end or is there a better way? Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您正在以一种很好的方式解决这个问题,但我认为当您考虑将管理员置于某个区域时,您已经完全正确了。我尝试在 Google 上搜索 Scott Gu 的某些领域的内容,但令人惊讶的是找不到任何专门针对它的内容,但有这篇 MSDN 文章:
使用区域组织应用程序
我知道您担心管理员具有类似操作(可能还有类似模型)的控制器以及前端,但分离逻辑可能仍然是最佳选择。不要过度思考或过度架构它,因为在某些时候,您可能必须修改管理控制器,而不是前端控制器。模型通常是控制器之间可以通用的点。
I believe you're going about this in a good way, but I think you're dead on when you were thinking about putting your Admin in an Area. I tried googling for something from Scott Gu for areas, but surprisingly couldn't find anything dedicated to it, but there is this MSDN article:
Organizing an Application using Areas
I know you're worried about having controllers with similar actions (and maybe similar models) with the admin as well as the frontend, but it's still probably optimal to separate the logic. Don't over-think or over-architect it, because at some point, you may have to modify the admin controller, but not the front-end controller. Models are typically the point that can be commonized between controllers.