I've a class that I want save in response cookie.
public IActionResult Get()
{
var data = JsonConvert.SerializeObject(new DeviceModel
{
Group = "TEST"
});
HttpContext.Response.Cookies.Append("dv-v3", data);
return Ok();
}
public class DeviceModel
{
[JsonProperty(PropertyName = "g")]
public string Group { get; set; }
[JsonProperty(PropertyName = "platform")]
public string Platform { get; set; }
}
But, encoded value is saved in cookie.
dv-v3=%7B%22g%22%3A%22TEST%22%2C%22platform%22%3Anull%7D; path=/
I want to cookie value be like this:
{"g":"TEST","platform":null}
How can I do this in asp.net core?