The issue is here:
public ActionResult Form(List<HttpPostedFileBase> files, DateTime dateParution, long IdJournal, string numEditionJournal)
If the modelbinder cannot find a DateTime
and long
by their respective names, it will pass null
. Since these types are non-nullable types, that function cannot be called (as the needed parameters are not present).
List<>
and string
are not problematic, as they can inherently be null
.
Solution: make the other types nullable (notice the added ? characters):
public ActionResult Form(List<HttpPostedFileBase> files, DateTime? dateParution, long? IdJournal, string numEditionJournal)
Note that using Nullable<long>
or long?
is equivalent. The same goes for any other type :)
Edit - Update
However, if these fields are required for you (it shouldn't ever be null to work correctly), you should look into client-side validation. There are many plugins to help you with this; and if you want to avoid dependencies, it's not that hard to do on your own.
At the very core, your webpage has to check if those form fields are entered correctly. If they are not, your webpage should not submit the form, but relay an error message to the user.