Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C# request sending cookie with request using httpclient
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Net; using System; using System.Net.Http; using System.Threading.Tasks; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Hello, world!"); /* if (args == null || args.Length != 1) { Console.WriteLine("Specify the URL to receive the request."); Environment.Exit(1); } */ var baseAddress = new Uri("http://requestb.in/122c1z31"); var cookieContainer = new CookieContainer(); using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer }) using (var client = new HttpClient(handler) { BaseAddress = baseAddress }) { var content = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("foo", "bar"), new KeyValuePair<string, string>("baz", "bazinga"), }); cookieContainer.Add(baseAddress, new Cookie("CookieName", "madhav")); var result = client.PostAsync("", content).Result; result.EnsureSuccessStatusCode(); } } } }
run
|
edit
|
history
|
help
0
azsdfghju654 ffddfdf
test
Composition
Does string contain only digits
nik
test type casting
Heap sort
input
compiled prog
Boggle