Async GET/POST and action name conflicts in ASP.NET MVC

后端 未结 1 1229
长情又很酷
长情又很酷 2021-01-03 07:28

The recommended way to make an edit page for ASP.NET MVC is to have two methods on a controller called Edit: one GET action and one POST action, both sharing the same name b

相关标签:
1条回答
  • 2021-01-03 07:55

    Generally the XyzAsync() method provides the XyzCompleted() method some state object that tells it what unit of work is being performed, so the XyzCompleted() method can inspect this object and do the right thing. However, if you want to have a different Completed method for each verb, this is possible via the following:

    [ActionName("Edit"), HttpGet]
    public void EditGetAsync() { }
    
    public ActionResult EditGetCompleted() { }
    
    [ActionName("Edit"), HttpPost]
    public void EditPostAsync() { }
    
    public ActionResult EditPostCompleted() { }
    
    0 讨论(0)
提交回复
热议问题