【发布时间】:2012-08-11 13:45:27
【问题描述】:
我正在尝试做这样的 POST:
HttpClient hc = new HttpClient();
byte[] bytes = ReadFile(@"my_path");
var postData = new List<KeyValuePair<string, string>>();
postData.Add(new KeyValuePair<string, string>("FileName", "001.jpeg"));
postData.Add(new KeyValuePair<string, string>("ConvertToExtension", ".pdf"));
postData.Add(new KeyValuePair<string, string>("Content", Convert.ToBase64String(bytes)));
HttpContent content = new FormUrlEncodedContent(postData);
hc.PostAsync("url", content).ContinueWith((postTask) => {
postTask.Result.EnsureSuccessStatusCode();
});
但我收到此异常:
无效的 URI:Uri 字符串太长。
抱怨这条线:HttpContent content = new FormUrlEncodedContent(postData);。对于小文件,它可以工作,但我不明白为什么对于较大的文件它不起作用?
当我发布 POST 时,content 可能会更大...那为什么它会抱怨 URI?
【问题讨论】:
标签: asp.net-mvc asp.net-web-api