将list与list串行化为url字符串并通过MVC控制器传递

时间:2016-12-20 12:47:40

标签: c# asp.net-mvc url

我有疑问可能是listize class with list to url string,之后传递给MVC控制器动作还有一些额外的参数,如public ActionResult Index(int? SomeId, Class Class)

public class Class
{
        public int Id { get; set; }
        public List<Item> Items { get; set; }
}

public class Item
{
    public int Id { get; set; }
    public string Name { get; set; }
}

将此类序列化为url:

var classToSerialize = new Class()
{
    Id = 1,
    Items = new List<Item>()
    {
        new Item() { Id = 1, Name = "Name1"},
        new Item() {Id = 2, Name = "Name2"}
    }
};

网址必须如何?

0 个答案:

没有答案