I'm trying to serialize and deserialize the model with properties/attributes. But I'm unable to do the properties. How to serialize model with attributes?
Model:
[Display(Name = "CreateCustomerView_FirstName")]
public string FirstName { get; set; }
[UIHint("DomainName")]
[Display(Name = "CreateCustomerView_LastName")]
public string LastName { get; set; }
Controller: Serialization:
cookie.Value = JsonConvert.SerializeObject(viewModel);
//var serializer = new JavaScriptSerializer();
//cookie.Value = serializer.Serialize(viewModel);
//cookie.Value = viewModel.ToString();
Deserialization:
viewModel= JsonConvert.DeserializeObject<viewModel>(Request.Cookies["cookie"].Value);