行动命名公约

sti*_*mms 25 model-view-controller asp.net-mvc

有人在MVC中建立了良好的行动命名约定吗?我特别关注ASP.net MVC,但这是一个普遍的问题.例如,我有一个显示登录屏幕(Login)的操作和一个处理该页面登录请求的操作(LoginTest).我并不热衷于这些名字,我还有很多应用程序要写.

Pau*_*non 41

MS的Rob Conery为动作提出了一些有用的REST风格命名.

* Index - the main "landing" page. This is also the default endpoint.
* List - a list of whatever "thing" you're showing them - like a list of Products.
* Show - a particular item of whatever "thing" you're showing them (like a Product)
* Edit - an edit page for the "thing"
* New - a create page for the "thing"
* Create - creates a new "thing" (and saves it if you're using a DB)
* Update - updates the "thing"
* Delete - deletes the "thing"
Run Code Online (Sandbox Code Playgroud)

导致网址(对于论坛)

* http://mysite/forum/group/list - shows all the groups in my forum
* http://mysite/forum/forums/show/1 - shows all the topics in forum id=1
* http://mysite/forums/topic/show/20 - shows all the posts for topic id=20
Run Code Online (Sandbox Code Playgroud)

Rob Conery关于MVC的RESTful架构

  • 链接死 - 有上Archive.org快照 - http://web.archive.org/web/20130119131317/http://wekeroad.com/2007/12/06/aspnet-mvc-using-restful-architecture (3认同)