紧密耦合视图投射问题

本文关键字:问题 视图 耦合 | 更新日期: 2023-09-27 18:01:47

这是我的对象

public class ProductContent
    {
        public Product Product { get; set; }
        public Location ProductLocation { get; set; }

    }

我有一个与Location对象紧密耦合的视图。

我有一个与ProductContent紧密耦合的视图在productcontent视图中,我输入

@Html.Partial("../PartialViews/Location", Model.ProductLocation)

我得到一个错误说

The model item passed into the dictionary is of type 'ProductContent', but this dictionary requires a model item of type 'Location'.

我正在传递模型。ProductLocation类型是location但为什么它仍然出错?

我使用MVC3 c# Razor

紧密耦合视图投射问题

这是asp.net mvc的RenderPartial的一个特性。当你传递null作为模型时,它使用父视图的模型。

ASP。. NET MVC,强类型视图,局部视图参数故障