I have an MVC 5.2.3 web project.
I have a model:
public class InstanceOnboarding : IInstanceOnboarding
{
public int ID { get; set; }
public int InstanceID { get; set; }
public string InstanceName { get; set; }
//etc...
}
And I am displaying the model with Html.EditorFor like so:
@Html.EditorFor(model => model, "InstanceOnboarding")
In Views/Shared/EditorTemplates I have my InstanceOnboarding.cshtml file that defines how EditorFor() is supposed to be mapping it:
@model Models.InstanceOnboarding
@Html.HiddenFor(model => model.ID)
@Html.HiddenFor(model => model.InstanceID)
@Html.HiddenFor(model => model.AuditFileID)
//etc...
However, when the page loads and I inspect element in Chrome, I see this:
<input ... id="ID" name="ID" type="hidden" value="240">
<input ... id="InstanceID" name="InstanceID" type="hidden" value="240">
even though 240 is the value of InstanceID
, and 0 is the value of ID
. I know they are because I can see them in the viewModel right before the page loads. Makes no sense!
Any idea how this is happening?
EDIT: I have experimented with setting the ID to not be 0; that doesn't make a difference.
EDIT 2: Showing controller method by request:
(The black areas are redacted information.)