Query string param is missed when form validation fail

前端 未结 3 1456
后悔当初
后悔当初 2020-12-21 06:22

I have an form with following url: CreateEntity?officeCodeId=5

When I send form to validate and if validation is fail it returns just CreateEntity u

3条回答
  •  难免孤独
    2020-12-21 06:50

    The problem is your HttpPost action doesn't have any notion of an id parameter. If you want to support a similar URL then make the action signature support that parameter e.g.

    [HttpGet]
    public ActionResult CreateEntity(int? officeCodeId)
    
    [HttpPost]
    public ActionResult CreateEntity(int officeCodeId, EditViewModel model);
    

提交回复
热议问题