如何在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