New and Create RESTful or Create Object Names for Both in ASP.MVC

The rails convention should use New and Create for RESTful action names. It is assumed that the .NET MVC convention uses Create for both (typically with a post delimiter in the action for the Create method).

Personally, I would prefer to use New and Create in .net, but used Create for both conditions. What (if any) is an advantage of the .NET MVC convention of using Create for both actions?

Can you say the same about Change and Update ?

+3
source share
1 answer

One of the advantages is that you can write code, for example:

<% using (Html.BeginForm()) { %>

... instead of a code like:

<% using (Html.BeginForm(new RouteValueDictionary{ "action", "Update" })) { %>

Similarly for error handling:

if (!ModelState.IsValid)
{
    return View(model);
}

... instead of:

if (!ModelState.IsValid)
{
    return View("Edit", model);
}

The MVC convention is that the related material is called the same, and not that your actions must have specific names.

+5
source

Source: https://habr.com/ru/post/1720103/


All Articles