我有一个 ViewModel,它是一个非常简单的过滤器对象,如下所示:
public class FilterViewModel
{
public String FilterTerm { get; set; }
public String FilterProperty { get; set; }
}
我希望做的是做一个从另一个页面到这个页面的路由链接,并将我的 FilterViewModel 传递到路由 url 创建到 RouteValues 中,如下所示:
Url.RouteUrl("myRoute", new { filter = new FilterViewModel() { FilterProperty = "Product", FilterTerm = _detail.FilterTerm }})"
瞧,另一边的渲染是
http://theurl?filter=Fully.Qualified.Namespace.FilterViewModel
我不知道我的预期,也许是像这样序列化到查询字符串中的东西:
http://theurl?filter=FilterProperty|Product,FilterTerm|ProductA
无论如何我要做的就是开箱即用?(或不开箱即用)