0

I have a controller action that looks like this

public class MyController : Controller
{
    [HttpPost]
    public int Save(int id, string someField, int someOtherField, byte[] content)
    {
    }
}

In another application I need to upload some data to this action either using WebClient or HttpWebRequest. How would I use one of these classes to upload data to this action?

Mathias Rönnlund
  • 4,078
  • 7
  • 43
  • 96
  • 1
    You can use https://msdn.microsoft.com/it-it/library/9w7b4fz7(v=vs.110).aspx `public byte[] UploadValues( string address, NameValueCollection data )` Creating a NameValueCollection of your post parameters – Flatlineato Mar 31 '16 at 11:02
  • @Flatlineato NameValueCollection only supports string values. For the numbers it's easy but is there any other way than to base64 code the byte array (which is a binary file)? – Mathias Rönnlund Mar 31 '16 at 13:21
  • http://stackoverflow.com/questions/11654562/how-convert-byte-array-to-string – Flatlineato Mar 31 '16 at 15:18

0 Answers0