Query string param is missed when form validation fail

前端 未结 3 1451
后悔当初
后悔当初 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:42

    Your final answer is excellent and works great, although you can further enhance it to make it more generic by simply including Request.QueryString:

    Then use the POST action:

    [HttpPost]
    protected virtual ActionResult CreateEntity(TEditViewModel model)
    {
        if (!ModelState.IsValid)
        {
            return View(model);
        }
    

提交回复
热议问题