I've got a viewpage with the inherits part looking like
Inherits="System.Web.Mvc.ViewPage<User>"
and a ViewUserControl with the inherits part looking like
Inherits="System.Web.Mvc.ViewUserControl<Address>
where User class (shortened) essentially looks like:
class User {
public virtual Address address { get; set; }
}
Now, if I try:
Html.RenderPartial("Address", Model.address);
then I potentially get some strange behaviour. In my case, it turns out Model.address was null Instead of passing null to the control, it looks like the framework tried to pass Model (i.e type=User) and was throwing an error (unexpected type).
Disregarding the fact that my address was null, is that behaviour of defaulting to the parent object a bug, or expected behaviour. If it is expected behaviour then can someone please explain why? I don't get it.