最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

(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

发布评论

评论列表(0)

  1. 暂无评论