Answer the question
In order to leave comments, you need to log in
How to pass cookies to a website through a C# console application?
I want to understand how to transfer a new cookie to the site.
I am using local server and domain, but the code below is not working.
How can I transfer cookies to the site in different ways (preferably in detail)? It seems to be sent, but in fact - no.
Code below:
public virtual System.Net.CookieContainer CookieContainer { get; set; }
private void button6_Click(object sender, EventArgs e)
{
string uri = "http://test/";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
System.Net.Cookie cook = new System.Net.Cookie("MyName", "rrrrrr", "/", "test");
request.CookieContainer = new CookieContainer();
request.CookieContainer.Add(cook);
if ( cook != null )
{
textbox.Text = cook.Name + " " + cook.Value;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question