Razor View Engine : An expression tree may not contain a dynamic operation

后端 未结 7 1931
不思量自难忘°
不思量自难忘° 2020-11-28 08:50

I have a model similar to this:

public class SampleModel
{
     public Product Product { get; set; } 
}

And in my controller I get an excep

7条回答
  •  天涯浪人
    2020-11-28 09:38

    It seems to me that you have an untyped view. By default, Razor views in MVC3 RC are typed as dynamic. However, lambdas do not support dynamic members. You have to strongly type your model. At the top of your view file add

    @model SampleModel
    

提交回复
热议问题