1.Page Controller
An object that handles a request for a specific page or action on a Web site.
在.NET里,可以定义一个BasePage继承于System.Web.UI.Page,然后其他具体的Page继承BasePage,Override里面的PageLoadEvent();此外,还需要定义一个Public View(比如Include文件,或者是User Control)用来存放Public Propery.
public class BasePage : Page
{
Public Property,比如登陆信息,站点信息,以及登陆验证,等重复性的劳动。减少代码的重复。
virtual protected void PageLoadEvent(object sender, System.EventArgs e)
{}
protected void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
PageLoadEvent(sender, e);
}
}
}
简单,一个页面一个Controller。
2.Front Controller,一个Controller来处理所有的Web请求。ASP.NET中,继承HTTPHandler来实现的。
分为2部分实现,Hanlder接收各个参数和信息,来选择合适的Command来执行;Command处理器,执行特定的命令,然后跳转到
特定的Page.
Handler : IHttpHandler;CommandFactory;
Web Config项:
<httpHandlers>
<add verb="*" path="Page*.aspx" type="Handler,FrontController" />
</httpHandlers>
UrlMap
类从应用程序的 web.config 文件加载配置信息。配置信息将所请求的 URL
的绝对路径关联到该文件所指定的另一个URL。
<controller.mapping>
<entries>
<entry key="/patterns/frontc/3/Page1.aspx" url="ActualPage1.aspx" />
<entry key="/patterns/frontc/3/Page2.aspx" url="ActualPage2.aspx" />
</entries>
</controller.mapping>
复杂,性能比较低,URL Mapping.
3. Template View, 通过embed Markers在HTML里面,来产生完整的页面信息。比如上面Page Controller里面的Public View( 比如Include文件 )
4. Transform View,通过XSLT来实现HTML页面的。
5.Two Step View,复杂,分为2步,一步产生Logic Page,第二步将Logic Page变成HTML.
6.Application Controller: A centralized point for handling screen navigation and the flow of an application.