I had been using this line at the top of my edit.cshtml page:
@using (Html.BeginForm())
but then I changed it to:
@using (Html.BeginForm("Edit", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
and now when I hit submit on that page I try to run this method:
public ActionResult Edit([Bind(Include = "description,tags,files,fileString")] Task task, int keyId, string editFiles)
I get this error:
The parameters dictionary contains a null entry for parameter 'keyId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Edit(Combined.Models.Task, Int32, System.String)' in 'Combined.Controllers.HomeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: The parameters dictionary contains a null entry for parameter 'keyId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Edit(Combined.Models.Task, Int32, System.String)' in 'Combined.Controllers.HomeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
I tried changing the line to:
@using (Html.BeginForm("Edit", "Home", FormMethod.Post, new { enctype = "multipart/form-data", keyId = Model.keyId }))
but it didn't make any difference. What am I doing wrong?