Id points to always null
I have an Edit method which always returns a null id: https://pastecode.io/s/upokmghg
I tried to map the Id (from the controller/model) on my cshtml but it did not help. Could anyone kindly point me in the right direction??
5 Replies
You have no form field with the name
id
Could you kindly point me what went wrong here .. I mean I tried to map the controller to the cshtml but the id is still null at my controller
My controller https://pastebin.com/cSzKufsU
My cshtml https://pastebin.com/rwqSwMV2 <--- I even created a form tag to mark the form field with the same Id in controller. Still none of these helped
Pastebin
public async Task EditListingJpost([FromForm]int? editSubmitId) //...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
The type of this input is text, while the controller expects an integer
Could you kindly point out which type in which input exactly you mean ? Please just point out which line out of the following cshtml
`
Let's see...
1. You posted code where you had an
id
parameter in the controller, and no name="id"
input in the form
2. You fixed that naming issue by renaming the parameter to editSubmitId
to match the form input name="editSubmitId"
3. I said that the input is of type="text"
while the parameter is an int?
Which, pray tell, input could I have in mind?