S
S
Stepgor2018-11-24 14:22:05
C++ / C#
Stepgor, 2018-11-24 14:22:05

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 question

Ask a Question

731 491 924 answers to any question