Remember that your patientId
and fullName
is found in the URL. Reassigning them to the ViewBag has nothing to do with it (remove the ViewBag and see what happens)
// Looks familliar? This is your first request.
Create?patientId=0&fullName=
The parameters is passed to the second Create
action method by default because the URL parameters is maintained.
// By default, parameters are not cleared during the second request.
Create?patientId=0&fullName=
When you set enctype = "multipart/form-data"
, the URL parameters gets cleared, resulting in something like this.
Create
Which means that it is the parameters that are lost and not the ViewBag data.
Related Problem: Form Post with enctype = "multipart/form-data" causing parameters to not get passed