我的 ASP.NET MVC 应用程序是否需要“管理员”?区域?
我基本上是在 asp.net mvc 中制作购物车。我正在添加一个管理员部分,管理员可以在其中:
- 对产品进行 CRUD。
- 对用户进行 CRUD。
- 订单上的 RUD。
我是否需要在 mvc 项目中为管理员创建一个管理员Area
,它适合我的需求吗? 区域
有什么好处?
I'm basically making a shopping cart in asp.net mvc. I'm adding an administrator section where the admins can:
- CRUD on Products.
- CRUD on Users.
- RUD on Orders.
Do I need to create an Administrator Area
in the mvc project for admins, is it suited for my needs? What are the benefits of an Area
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
区域
。如果您的需求可能在不久的将来扩大,那么这可能是有意义的。然而,到目前为止,您的需求相当简单,似乎创建一个ProductController
、一个UserController
和一个RUDController
会更容易,然后将AuthorizationFilter
应用于“管理员”操作。我建议你从这种方式开始,如果你将来需要添加额外的功能,那么你可以将功能重构为一个Area。在这一点上,它可能只是给自己做不必要的工作。编辑:当我第一次开始学习 MVC 时,我读了 Rob Conery 的一篇博客文章,其中解释了如何解决这个问题。我刚刚浏览了我的书签并为您找到了它。我想您会发现它很有帮助:http://blogs.msdn.com/b/rickandy/archive/2011/05/02/secure-your-asp-net-mvc-3-application.aspx
You could use an
Area
. If your needs are likely to expand in the near future, then it might make sense. However, as of now your needs are fairly simple, and it seems like it would be easier to create aProductController
, aUserController
and aRUDController
, then apply anAuthorizationFilter
to the "administrator" actions. I suggest you start this way, and if you need to add additional functionality in the future, then you can refactor the functionality to an Area. At this point, it would probably just be making unnecessary work for yourself.EDIT: When I first started learning about MVC I read a blog post by Rob Conery that explained how to approach this problem. I just looked through my bookmarks and found it for you. I think you'll find it helpful: http://blogs.msdn.com/b/rickandy/archive/2011/05/02/securing-your-asp-net-mvc-3-application.aspx