ASP.NET MVC控制器动作设计 [英] ASP.NET MVC controller actions design

查看:128
本文介绍了ASP.NET MVC控制器动作设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很喜欢的方式ASP.NET MVC的作品。我很想实现它在所有新的Web项目向前发展,但我的原型,我真的还没有找到一个很好的解决方案有一天遇到了障碍,所以我问你,你会怎么设计一个MVC应用程序不符合典型的REST模式?作为一个例子,我被设计原型将有几页,但页本身不一定绑定到域模型。例如,以一个简单的注册网站,这可能有以下网页:

I really like the way ASP.NET MVC works. I'd love to implement it on all new web projects moving forward, but I hit a snag in a prototype the other day that I really haven't found a good solution for, so I ask you, how would you design an MVC app that doesn't fit the typical REST pattern? As an example, the prototype I was designing would have several pages, but the pages themselves aren't necessarily bound to a domain model. For example, take a simple registration site, which might have the following pages:


  • /Default.aspx

  • /Register.aspx

  • /ThankYou.aspx

有时,这样的程序可能需要一个管理部分处理这些细节放缓迹象起坐或审查数据。在标准的ASP.NET Web应用程序,我可以添加以下

Occasionally, such a program might require an admin section to deal with such details as moderating sign ups or reviewing data. In a standard ASP.NET web app, I might add the following


  • /Admin/Default.aspx

  • /Admin/ListRegistrations.aspx

  • /Admin/ViewReports.aspx ...

难道是从MVC模式不可接受的偏差,在这种情况下,有两个控制器,例如:

Would it be an unacceptable deviation from the MVC pattern, in this case, to have two controllers such as:


  • 首页>首页

  • 首页 - >注册

  • 首页 - >三江源

  • 管理 - >首页

  • 管理 - > ListRegistrations

  • 管理 - >报告

我与此挫折是由这一事实没有真正的固体执行子控制器和区域的又复杂。我知道了区的原型由菲尔哈克放在一起的,但它不是很成熟,很坦率地说,我不知道我喜欢它的设置的方式,但我真的不知道我是怎么想看到工作无论是。

My frustration with this is compounded by the fact that there is no real solid implementation of subcontrollers and areas yet. I'm aware of the "Areas" prototype put together by Phil Haack, but it's not very mature, and quite frankly, I'm not sure I like the way it's setup, but I don't really know how I'd like to see that work either.

我想,当我想MVC,我倾向于认为REST为好,并具有重新present页面,而不是实际的实体或动作不正确的坐我控制器动作。你觉得呢?

I guess when I think MVC, I tend to think REST as well, and having controller actions that represent pages rather than actual entities or actions doesn't sit right with me. What do you think?

推荐答案

您总是可以混合使用MVC ASP.NET Web窗体。

You can always mix ASP.NET Web Forms with MVC.

只需添加

routes.IgnoreRoute("Pages/{*path}");

要你的路由表,并添加传统的Web表单页面应用程序的文件夹中。

to your routing table and add traditional Web form pages to Pages folder of the application.

这篇关于ASP.NET MVC控制器动作设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆