c# - Uri string is too long when attempt to post a large payload - Stack Overflow

(I checked on Network tab for the website itself and it can upload ~1500lines of code)When I try to

(I checked on Network tab for the website itself and it can upload ~1500 lines of code) When I try to execute the code,

Error: System.UriFormatException: InvalidURI: The Uri string is too long.

if (Input.Text.Replace(" ", "").Length == 0) {
    PGD.Content = "You must fill out the text box!";
    return;
}
try
{
    using (var wc = new HttpClient())
    {
        wc.DefaultRequestHeaders.Add("User-Agent", "FlameIgniterDPasteTool");
        var x1 = new MultipartFormDataContent
        {
            { new StringContent(Uri.EscapeDataString(Input.Text), Encoding.UTF8, "application/x-www-form-urlencoded"), "content" }
        };
        HttpResponseMessage res = await wc.PostAsync("/", x1);
        PGD.Content = res.Content.ReadAsStringAsync();
    }
}
catch (Exception ex) {
    PGD.Content = "Error: " + ex.ToString();
}
Progress.IsEnabled = false;
await Task.Delay(1000);
Progress.IsEnabled = true;

Input.Text -> A text box for user to enter to be posted to DPaste

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745628370a4636950.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信