What am I misunderstanding about how Html.TextBoxFor works

前端 未结 3 1529
旧时难觅i
旧时难觅i 2021-01-05 03:02

I\'m just trying to get back into .NET MVC with the new release and I can\'t get my head round the way may view is binding to the DataModel.

I have a model with a pr

3条回答
  •  情歌与酒
    2021-01-05 04:07

    You need to clear your model state so your code would look something like:

    [HttpPost]
    public ActionResult Register(Registration model)
    {
        ModelState.Clear();
        model.first_name = "Steve";
        return View(model);
    }
    

提交回复
热议问题