ASP.NET MVC - using the same form to both create and edit

前端 未结 10 822
温柔的废话
温柔的废话 2021-01-30 05:27

Whats the best practice approach to creating a form that is used to both create new models and edit existing models?

Are there any tutorials that people can point me in

10条回答
  •  难免孤独
    2021-01-30 05:47

    I use something like

    [HttpGet]
    public ActionResult EntityEdit(Guid id)
    {
        return View();
    }
    

    and

    [HttpGet]
    public ActionResult EntityCreate()
    {
       return View("EntityEdit");
    }
    

    That seems to work OK.

提交回复
热议问题