WebClient definir cabeçalhos
Como posso definir um cabeçalho nowebClient
classe? Eu tentei
client.Headers["Content-Type"] = "image/jpeg";
que lança umWebException
Meu código:
WebClient client = new WebClient();
client.Headers.Set("Content-Type", "image/png");
client.Headers.Set("Content-Length", length);
client.Headers.Add("Slug", name);
NameValueCollection nvc = new NameValueCollection();
nvc.Add("file", FileContents);
Byte[] data = client.UploadValues(url, nvc);
string res = Encoding.ASCII.GetString(data);
Response.Write(res);