How to store and receive a byte array in hidden field?

c#

Solution

You'll need to store it in the hidden field as a string, so you could do:

hiddenField.Value = Convert.ToBase64String(data);

And then convert it back later:

byte[] data = Convert.FromBase64String(hiddenField.Value);

It would be a bit more thorough if you could provide an example of the data, too.

Problem

I have a byte array. I need to assign it to a hidden filed and retrieve the result.How to achieve this? I tried ``` var data =(byte[])hiddenField.value ; ``` but its giving a error cannot convert string to bytearray.

Original source