❔ CRud in .net core mvc Image file return as null from view to controller
I am doing crud of registration which includes submitting and dynamically retrieving all kinds of ui control like checkboxes dropdownbox text field and image file.
Created table in db and scaffolded the model. And I wrote the action methods in controller.But no loading in page.In create submitting method, modelstate.IsValid is false.
I have 5 field
Id(pk,identity )
Name
Email
Gender(dropdown)
Mobile
Country(checkboxes multiple selections)
ProfileImage(Image file)
I have pasted code
MY Views
https://paste.mod.gg/zbtemoilfwiw/0
my action
https://paste.mod.gg/rmuneguvbize/0
Not load any data in Index and create view not submitting to controller
pls help!
BlazeBin - zbtemoilfwiw
A tool for sharing your source code with the world!
BlazeBin - rmuneguvbize
A tool for sharing your source code with the world!
3 Replies
Use parameter binding, not
Request.Form
tomfoolery with magic stringsOh okay
Now this issue is image comes a null in the entry of Create Method. Even though all other values of form I could fetch using Request.Form.That is fine. Now the issue is image.
My create : public IAction Create(RegModel reg, IFormGile image)
(
)
Here I get IFormfile at the entry, but reg object does not hv image it display null.So my ModelState.Valid fails.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.
Was this issue resolved? If so, run /close
- otherwise I will mark this as stale and this post will be archived until there is new activity.