Recommendation: Don't use the same action names for get and (Ajax) post.
I am always amazed at how bad Microsoft's code examples are. Code generated using the default templates in Visual Studio is not much better. To find out, create an empty project (pick your favorite type) and run static code analysis or FxCop and see how many warnings you see. For some real fun try running StyleCop. The default templates (and therefore commonly-used standard practices) are also not very good in my opinion. Consider the following controller code generated using the standard MVC 3 template:
//
// GET: /Test/Create
public ActionResult Create()
{
return View();
}
//
// POST: /Test/Create
[HttpPost]
public ActionResult Create(FormCollection collection)
{
try
{
// TODO: Add insert logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
For those of you who have used MVC for a while, this looks pretty standard. "So what's the big deal?" you ask. Here is my beef: there is no value to having two controller actions named "Create". My personal opinion, is that this convention was used to smooth the transition from web forms. The first Create method would be similar to a Page_Load event handler and the second one would be similar to a Button_Click event handler. To use more web form language, the first method handles the initial request and the second one handles the "postback". For people used to dealing with web forms, it makes it more obvious that these two methods are dealing with the same "page". The only real advantage is that you don't have to specify the action name in Html.BeginForm. This can be a good thing because it eliminates a magic string from your view.
So let's examine this more closely and see where we start running into problems. For the sake of argument, let's say that this is a search page. Therefore you want to use a GET transaction instead of POST so the user can see the URL, bookmark it to re-run their search, etc. You remove the [HttpPost] attribute. You will now get an error that the action is ambiguous between action methods.
The solution to this problem is simple, just rename one of the methods. My recommendation is to call the first method "New". This then maps to the nice route "/{controller}/New". In general this is something users expect to see in a URL - what they are looking at so I like to use nouns or adjectives for these actions (Details, New, Info, Order, Product, etc.). The form would then call the "Create" action. In this case I like to make my actions that do something use verbs (Create, Update, Delete, List, Rename, etc.).
This convention really starts to make even more sense once you start having multiple Ajax calls from a single page. After all, why use a paradigm based on full-page posting (Html.BeginForm in MVC) when most applications will use partial-page posts or other script-based methods?