惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
T
Threatpost
P
Palo Alto Networks Blog
NISL@THU
NISL@THU
O
OpenAI News
Project Zero
Project Zero
G
GRAHAM CLULEY
P
Privacy International News Feed
A
Arctic Wolf
Microsoft Azure Blog
Microsoft Azure Blog
H
Help Net Security
M
MIT News - Artificial intelligence
T
Threat Research - Cisco Blogs
S
Security @ Cisco Blogs
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
D
Docker
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
W
WeLiveSecurity
P
Proofpoint News Feed
腾讯CDC
Cloudbric
Cloudbric
S
Secure Thoughts
C
Check Point Blog
博客园 - Franky
T
The Exploit Database - CXSecurity.com
T
Troy Hunt's Blog
GbyAI
GbyAI
Security Archives - TechRepublic
Security Archives - TechRepublic
Application and Cybersecurity Blog
Application and Cybersecurity Blog
月光博客
月光博客
C
Cyber Attacks, Cyber Crime and Cyber Security
I
Intezer
TaoSecurity Blog
TaoSecurity Blog
L
Lohrmann on Cybersecurity
V
Visual Studio Blog
F
Fortinet All Blogs
博客园 - 叶小钗
C
CXSECURITY Database RSS Feed - CXSecurity.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
C
Cisco Blogs
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - everx

CruiseControl.net - 找到的一些文档。分享出来 【摘抄】回归测试(Regression Test) 那就来说说ASP.NET MVC中的Routing吧 ASP.NET MVC - View ASP.NET MVC - Controller(part Ⅱ) ASP.NET MVC - Model 学一下ASP.NET MVC C# 3.0的新特性 jQuery学习笔记(八) jQuery 学习笔记(七) SilverLight学习之路(四) Silverlight学习之路(三) - everx - 博客园 JQuery学习笔记(六) JQuery学习笔记(五) 初次使用log4net Silverlight学习之路(二) JQuery学习笔记(四) 播下silverlight的种子 JQuery学习笔记(三)
ASP.NET MVC - Controller(part Ⅰ)
everx · 2009-10-15 · via 博客园 - everx

Model已经简单的看过了,在深入下去可能要讨论如何针对领域建模还有相关的设计模式等等,不是一两句能说清楚的。那么,这次就把眼光全部聚焦在Controller上吧。
首先,要了解Controller的作用。如果没有Controller的话呢,所有的请求到要被导向View里面去,无形中使得View变得臃肿且不好维护,像是之前的WebForm。所以,Controller就是为了把处理请求这部分功能挪出来,才诞生的。

然后,Controller的根本是IController接口。这个接口只有一个方法,即:void Excute(RequestContext)。这个方法是在请求到来时,由MVCHandler来执行Controller的Excute方法,这样也就到达了我们编写的各个Action方法。在这里,Controller可以发挥它的枢纽作用。

接着,是Action了。实质上,Action就是一个方法,根据不同的请求调用不同的Action。类似于,WebForm时期的一个个Page。这样说,其实不准确,有点类似于Page_Load的那个方法,请求某个页面时,自动运行这个方法。呵呵,有点说多了。Action可以接受0个或者多个参数,这些参数是由Form数据、Route数据和QueryString。返回值是ActionResult类型,这是个抽象类。如果返回类型不是ActionResult的话,也可以,MVC架构会自动调用返回类型的ToString()方法,然后把它封装成一个ContentResult(派生类)并返回。他有很多的派生类,用到哪再说到哪了,一一列举也没什么劲。:) 简而言之,它的作用就是利用参数,传递给下层模型,然后生成表现模型,通过ViewData传给View。

刚刚说到了ViewData,这个就是连接Controller和View的纽带。可以把它当作一个IDictionary<string, object>来看待就行了,当然ViewData还有一个Model属性,也可以用来传递数据。

好了,就先说到这了,说了不少东西的感觉。呵呵!改天继续~