如何在webClient
类中设置标题? 我想:WebClient设置标题
client.Headers["Content-Type"] = "image/jpeg";
抛出一个WebException
我的代码:
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);
异常详细信息:System.Net.WebException:对于此请求,Content-Type标头不能从其默认值更改。 –
回复更新... – jdc0589
更新后... – jdc0589