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

  • SEARCH
  • Home
  • 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 6031659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:13:01+00:00 2026-05-23T05:13:01+00:00

private void button1_Click(object sender, EventArgs e) { string userName = textBox1.Text; string password =

  • 0
private void button1_Click(object sender, EventArgs e)
{
    string userName = textBox1.Text;
    string password = textBox2.Text;
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.youmint.com/LoginVerification.php?name="+userName+"&pass="+password+"&agreement=true&checkvalue=true");
    request.Method = "GET";
    request.KeepAlive = true;
    request.Headers.Add("Keep-Alive: 300");
    WebResponse response = request.GetResponse();
    Stream dataStream = response.GetResponseStream();
    StreamReader reader = new StreamReader(dataStream);
    string responseFromServer = reader.ReadToEnd();
    if (responseFromServer.Equals(""))
        MessageBox.Show("Successfully logged in!!");
    else if (responseFromServer.Equals("1"))
        MessageBox.Show("Login failed!");
    request = (HttpWebRequest)WebRequest.Create("http://www.youmint.com/FreeSms.html");
    response = request.GetResponse();
    dataStream = response.GetResponseStream();
    reader = new StreamReader(dataStream);
    responseFromServer = reader.ReadToEnd();
    /*secret code :P */
    reader.Close();
    dataStream.Close();
    response.Close();
 }

So, that’s my code… The first webrequest logs into the website. It works fine in the browser and returns 1 if the login is not correct. Then the second one is a normal webrequest to a webpage of the same website. But the login is already gone and the response I get is what I get if I’m not logged in! Can someone please tell me what I’m doing wrong? How do I keep it alive? Do I have to use an invisible webbroswer control or something like that?

  • 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-23T05:13:02+00:00Added an answer on May 23, 2026 at 5:13 am

    @liho1eye is correct. Here’s some more info from the HttpWebRequest page:

    For security reasons, cookies are
    disabled by default. If you want to
    use cookies, use the CookieContainer
    property to enable cookies.

    You’ll need to reference the HttpWebResponse.Cookies property to get the initial session token cookie.

    Edit:

    Here’s a quick and dirty sample of making a request to a page, and transferring response cookies to the next request. Didn’t do much testing or validation (so beware!) – just to give you the idea of the approach.

            //this only has login/password info, you may need other parameters to trigger the appropriate action:
            const string Parameters = "Login1$username=pfadmin&Login1$Password=password";
    
            System.Net.HttpWebRequest req = (HttpWebRequest)System.Net.WebRequest.Create("http://[WebApp]/Login.aspx");
    
            req.Method = "GET";
            req.CookieContainer = new CookieContainer();
            System.Net.HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
    
            //Create POST request and transfer session cookies from initial request
            req = (HttpWebRequest)System.Net.WebRequest.Create("http://localhost/AdminWeb/Login.aspx");
            req.CookieContainer = new CookieContainer();
            foreach (Cookie c in resp.Cookies)
            {
                req.CookieContainer.Add(c);
            }
            req.ContentType = "application/x-www-form-urlencoded";
            //...continue on with your form POST
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

private void button1_Click(object sender, EventArgs e) { string name; name = textBox5.Text; SqlConnection con10
private void LoginButton_Click(object sender, EventArgs e) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(loginUrl); IAsyncResult
private void button1_Click(object sender, EventArgs e) { Insert(); } private int Insert() { string
When I run the following code: private void button1_Click(object sender, EventArgs e) { Bitmap
i am tying to login using System.Diagnostics.Process.Start private void button1_Click(object sender, EventArgs e) {
private void button1_Click(object sender, EventArgs e) { using (SqlConnection sqlConn = new SqlConnection(Data Source=TANYA-PC;Initial
private ScriptEngine pe; private ScriptScope scope; private void button1_Click(object sender, EventArgs e) { pe
private void showCategory_Load(object sender, EventArgs e) { string categoryId = 100 } private void
. private void Form1_Load(object sender, EventArgs e) { List<CaclulatedData> tests = new List<CaclulatedData> {
public partial class Form3 : Form { string var; int ID1; private void button1_Click(object

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.