我正在尝试使用properties / attributes序列化和反序列化模型。但我无法做这些属性。如何使用属性序列化模型?
型号:
[Display(Name = "CreateCustomerView_FirstName")]
public string FirstName { get; set; }
[UIHint("DomainName")]
[Display(Name = "CreateCustomerView_LastName")]
public string LastName { get; set; }
控制器: 序列:
cookie.Value = JsonConvert.SerializeObject(viewModel);
//var serializer = new JavaScriptSerializer();
//cookie.Value = serializer.Serialize(viewModel);
//cookie.Value = viewModel.ToString();
反序列化:
viewModel= JsonConvert.DeserializeObject<viewModel>(Request.Cookies["cookie"].Value);