MvcContrib(上)
赵劼架构师上海柏盛
网络技术有限公司柏术
点击添加MSN机器人小新为您收听下载MSDN中文网络广播
课程加油助力!
收听本次课程需具备的条件
了解ASP.
NETMVC基本开发特性本特性
Level200
MvcContrib
开源项目
–公开
源代码?公开源代码
利用ASP.NETMVC框架中的扩展点
–EtdeverywhereExtendh
开发辅助
–Resharper模板–CodeSnippet
TestHelpers
MvcContrib中的几个扩展(部分)
ViewHelpers
–Gridhelperp–ValidationHelper
CtllBControllerBase
–ConventionController
Routing
–SimplyRestfulRouting
ViewHelpers
方便生成特定格式的内容或功能生特格式容功GridHelper
–根据数据生成一个表格
ValidationHelper
–使用ASP.NET自带的验证脚本生成验证功能使带脚本
FormHelper
–生成F生成Form相关Tag相关T–并未超越框架中的Helper方法
Demo1
GridHelperValidationHelper
ConventionController
Controller基类,提供了更高级的方法类提供高法更高级的参数序列化方法更丰富的错误处理办法
Demo2
ConventionController
REST
REST:RepresentationalStateTransfer一种分布式
系统的架构方式,由RoyFielding提出Fildi提出一种特定的实现是基于HTTP,充分利用起种特定实现是充分利用HTTP作为一种应用协议的各种特性
–HttpMethod:GET/POST/PUT/DELETE–StatusCode:2XX,3XX,4XX,5XX–Cache:Cache-Control,ETag,etc.–etc.
SimplyRestfulRouting
根据URL和HTTP方法决定特定的Action根据URL和HTTP方法决定特定的Action:
ActionIndexShowEditDeleteNewCreateUpdateDestroyHTTPMethodGETGETGETGETGETPOSTPUTDELETEDefaultUrl[controller][controller]/[id][controller]/[id]/edit[controller]/[id]/delete[controller]/new[controller][controller]/[id][controller]/[id]DescriptionpGetsacollectionofresourcesGetsasingleresourceidentifiedbyidGetsaformtoeditresourcesidentifiedbyidGetsaformtoconfirmadeleteoftheresourceidentifiedbyidGetsformt
oacreateanewresourceCreatesthenewresourceUpdatestheresourceidentifiedbyidDeletestheresourceidentifiedbyid