Has anybody established a good naming convention for action in MVC? I was specifically looking at ASP.net MVC but it is a general question. For instance I have an action which displays the login screen (Login) and one which process the login request from that page (LoginTest). I'm not keen on the names and I have a lot of the applicaiton left to write.
The builtin Django actions suffix _done. So LoginDone would be the page that processes Login (in ASP.NET MVC camel case style).
It's fairly irrelevant which convention you use for the Controller Action naming, as long as it's consistant for you and easily understood by those working on it.
In the case of your login Actions, LoginDone is fine and in the same was ProcessLogin will is easy to understand, so use a convention that you feel comfortable with.
Personally I would probably side with Login and ProcessLogin, as LoginDone is probably slightly misleading in terms of what the Action is doing - this is of course assuming that the Action is reacting to the users' credentials and checking whether they are valid. You could then pass through to another Action called LoginDone once the login is successful, or LoginFailed if it's not.
Rob Conery at MS suggested some useful RESTful style naming for actions.
* 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"
results in URLs along the lines of (for a forum)
* 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
I've found a blog post by Stephen Walther useful for finding a consistent naming scheme. His are also derived from a REST-style naming scheme, with some unique exceptions that he explains.