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 301893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:02:51+00:00 2026-05-12T07:02:51+00:00

There are many sites which call a script upon form submit and pass in

  • 0

There are many sites which call a script upon form submit and pass in parameters using HTTP POST or GET, using a web debugger i have found the parameters being passed. Now i wish to do the same thing through my Windows Application in C#. How can i achieve such a functionality?

I am currently using HttpWebRequest and HttpWebResponse class in C#. But it is a pain as i have to write explicit code for each page i try to load and work. For Example i am trying to pass username and password to a php page and taking the response, which will send a cookie and a page in return, based on which i identify if the user has logged in or not.

HttpWebRequest loginreq = createreq("http://www.indyarocks.com/mobile/index.php");
                String logintext = "username=" + TxtUsrname.Text + "&pass=" + TxtPasswd.Password + "&button.x=0&button.y=0";
                loginreq.ContentLength = logintext.Length;
                StreamWriter writerequest = new StreamWriter(loginreq.GetRequestStream());
                writerequest.Write(logintext);
                writerequest.Close();
                HttpWebResponse getloginpageresponse = (HttpWebResponse)loginreq.GetResponse();
                cookie = getloginpageresponse.Cookies[0];
                BinaryFormatter bf1 = new BinaryFormatter();
                Stream f1 = new FileStream("E:\\cookie.dat", FileMode.OpenOrCreate);
                bf1.Serialize(f1, cookie);
                f1.Close();

                string nexturl = getloginpageresponse.Headers[HttpResponseHeader.Location];
                StreamReader readresponse = new StreamReader(getloginpageresponse.GetResponseStream());
                if (nexturl == "p_mprofile.php")
                {
                    MessageBox.Show("Login Successful");
                    GrpMsg.IsEnabled = true;
                }
                else if (nexturl == "index.php?msg=1")
                {
                    MessageBox.Show("Invalid Credentials Login again");
                }

This is my createreq class

 private HttpWebRequest createreq(string url)
        {
            HttpWebRequest temp = (HttpWebRequest)WebRequest.Create(url);
            temp.Method = "POST";
            temp.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 3.5.21022; FDM)";
            temp.KeepAlive = true;
            temp.ContentType = "application/x-www-form-urlencoded";
            temp.CookieContainer = new CookieContainer();
            temp.AllowAutoRedirect = false;
            return temp;
        }

Am i on the right track? Is there any better way to do it?

  • 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-12T07:02:52+00:00Added an answer on May 12, 2026 at 7:02 am

    You should use System.Net.WebClient.

    You can use it to make a request with any method and headers that you’d like, and get the resulting page with a simple stream read.

    There’s a simple example on the MSDN page, but some sample code for using it might look like:

    WebClient webclient= new WebClient();
    
    using (StreamReader reader = new StreamReader(webclient.OpenRead("http://www.google.com")))
    {
            string result = reader.ReadToEnd();
             // Parse web page here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 207k
  • Answers 207k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I suppose it's entirely possible with reflection, with the aid… May 12, 2026 at 9:19 pm
  • Editorial Team
    Editorial Team added an answer Alternatively, you could attach another event handler to the input… May 12, 2026 at 9:19 pm
  • Editorial Team
    Editorial Team added an answer I would speculate that your first test [test1 count] ==… May 12, 2026 at 9:19 pm

Related Questions

On my forum-based website, I have a link below every post for reporting spam
I'm working on a Web service in Django, and I need to model a
We are beginning to go down the path of mobile browser support for an
I have been getting an error message that I can't resolve. It originates from

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.