最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin5PV0评论

(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

Post a comment

comment list (0)

  1. No comments so far