So previously this view was bound to only one model but now I am using:
@model Tuple<Namespace.Models.Model1, Namespace.Models.Model2>
So now when I bind:
@Html.HiddenFor(p => p.Id);
The compiler does not know which model to use and as a result throws this error:
The type arguments for method 'InputExtensions.HiddenFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
I tried to explicitly infer the model using:
@Html.HiddenFor(Model1 => Model1.Id);
But I get:
The type arguments for method 'InputExtensions.HiddenFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
So I try the below:
@Html.HiddenFor<TModel, TProperty>(HtmlHelper<TModel> p => p.Id);
The Id property is defined in Model1.
And get a whole bunch of other errors. After extensive reading online, I still have not found a solution. How do I get around this?