在View中使用@model  List<dynamic>中是类型dynamic时会出现此问题
我整理了下处理方法如下

首先项目中加入下面的类

namespace System
{
    public static class ExpandoHelper
    {
        public static ExpandoObject ToExpando(this object anonymousObject)
        {
            IDictionary<string, object> anonymousDictionary = new RouteValueDictionary(anonymousObject);
            IDictionary<string, object> expando = new ExpandoObject();
            foreach (var item in anonymousDictionary)
                expando.Add(item);
            return (ExpandoObject)expando;
        }

    }
}

此处注意namespace System不可更改

然后在声明dynamic类型后加入.ToExpando()方法

   dynamic param = new
            {
                Logo= "TruckTransport"
                page = 1,
                row = 10
            }.ToExpando();

 

 

 

解决方式:使用  ExpandoObject类

  

1
2
3
dynamic viewModel = new ExpandoObject();
        viewModel.UserID = 5016;
        return View(viewModel);

@Model.UserID  处理结果为 :