Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6920363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:08:13+00:00 2026-05-27T10:08:13+00:00

I am making a program that get’s it’s data from a site that needs

  • 0

I am making a program that get’s it’s data from a site that needs authentication. I am making the program in a console, so I cannot use controls.

I am able to send the user data to the login form and get the information of the welcome screen. But when I send another request, the site forgot I ever logged in.
I read that I had to enable cookies somehow, but I haven’t worked it out yet.

This is my code:

public string GetResponse()
{
    // Build a string containing all the parameters
    string Parameters = string.Empty;
    foreach (string p in theQueryData)
    {
        Parameters += string.Format("&{0}", p);
    }

    if (Parameters.Length > 0)
        Parameters = Parameters.Substring(1);

    // Create a request using a URL that can receive a post. 
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.url);

    // Set the Method property of the request to POST.
    request.Method = this.method;
    // Create POST data and convert it to a byte array.
    string postData = Parameters;
    byte[] byteArray = Encoding.UTF8.GetBytes(postData);
    // Set the ContentType property of the WebRequest.
    request.ContentType = "application/x-www-form-urlencoded";
    // Set the ContentLength property of the WebRequest.
    request.ContentLength = byteArray.Length;
    // Get the request stream.
    Stream dataStream = request.GetRequestStream();
    // Write the data to the request stream.
    dataStream.Write(byteArray, 0, byteArray.Length);
    // Close the Stream object.
    dataStream.Close();
    // Get the response.
    WebResponse response = request.GetResponse();
    // Get the stream containing content returned by the server.
    dataStream = response.GetResponseStream();
    // Open the stream using a StreamReader for easy access.
    StreamReader reader = new StreamReader(dataStream);
    // Read the content.
    string responseFromServer = reader.ReadToEnd();
    // Clean up the streams.
    reader.Close();
    dataStream.Close();
    response.Close();

    return responseFromServer;
}

These are the headers the request returns:

Connection: keep-alive
Vary: Accept-Encoding
Content-Length: 7628
Cache-Control: private
Content-Type: text/html
Date: Tue, 06 Dec 2011 20:58:21 GMT
Set-Cookie: plaza%5Fmasteraccount=; expires=Tue, 06-Dec-2011 23:00:00 GMT; domain=; path=/,plaza%5Fvacmode=R; expires=Tue, 06-Dec-2011 23:00:00 GMT; domain=; pa
th=/,plaza%5Fname=%16%05%0C%0E%15%09%18%21QRQ; expires=Tue, 06-Dec-2011 23:00:00 GMT; domain=; path=/,plaza%5Flocked=R; expires=Tue, 06-Dec-2011 23:00:00 GMT; d
omain=; path=/,plaza%5Flogin=%16%05%0C%0E%15%09%18%21QRQ; expires=Tue, 06-Dec-2011 23:00:00 GMT; domain=; path=/,plaza%5Fid=S%5ENWNSQPP%40%15%08%0C%0E%15%09%18%
21QRQ%15%08%0C%0E%15%09%18%21QRQRQQ; expires=Tue, 06-Dec-2011 23:00:00 GMT; domain=; path=/,plaza%5Fmid=1323205117; expires=Sun, 25-Nov-2012 23:00:00 GMT; path=
/,plaza%5Fstatus=Q; expires=Tue, 06-Dec-2011 23:00:00 GMT; domain=; path=/,ASPSESSIONIDSQCRSDDR=NKHJIBADOGALNGKDBALDJBIA; path=/
Server: nginx
X-Powered-By: ASP.NET
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:08:14+00:00Added an answer on May 27, 2026 at 10:08 am

    You need to add a cookie container.

    CookieContainer cookieContainer = new CookieContainer();
    // Create a request using a URL that can receive a post. 
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.url);
    request.CookieContainer = cookieContainer;
    
    //DO your request that sets cookies from the server.
    .........
    
    //Place another request with the cookies
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(someNewUrl);
    request.CookieContainer = cookieContainer;
    //this should have cookies from the previous request, which should keep you logged in.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a program that reads and stores data from Windows EventLog files
hey, am making a program that makes the forms and controls dynamically from xml
I'm making a C program where I need to get the directory that the
I'm making a program that retrieves decently large amounts of data through a python
I'm making a program that takes names from the user seperated by commas. The
I am making a simple program which suppose to accept txt file data from
I'm making a program that can access data stored inside a class. So for
I am making a program that import emails from txt files and send a
I'm making a program that will display a few images from a directory beside
I am making a program that loads videos from a server and then saves

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.