Do the controller action parameters automatically view input tags?

I have a controller with an action having a parameter (JobID). I was surprised to see that it automatically maps to a hidden field with the same name in the view that the controller returned. I use strongly typed view models and assume that I need to pass all the model properties as part of the view model. It seems that this is not so.

I know that the view fields return to the action parameters on the called controllers, but they don’t understand that this works in both directions. Do I understand this correctly? Any errors with this?

+3
source share
1 answer

HTML- , (POST GET), ViewData. - .

, , , . , , POST:

[HttpPost]
public ActionResult Index(Job job)
{
    job.JobID = 10;
    return View();
}

jobID = 5. 10, html 5 .

+2

Source: https://habr.com/ru/post/1770006/


All Articles