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
  • 1 View
  • 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

Related Questions

There are many online judge sites which can verify your program by comparing its
There are many conflicting statements around. What is the best way to get the
There are many ways of converting a String to an Integer object. Which is
There're many ways to write an HTTP-status header: HTTP/1.1 404 Not Found Status: 404
I have a Database storing details of products which are taken from many sites,
How do I go about learning web typography? I see many sites using nice
Was just wondering how do these sites (and many other softwares that generate flash
There are many things that all programmers should know, but I am particularly interested
There are many instances where we are not happy with the decisions that Oracle's
There are many systems that depend on the uniqueness of some particular value. Anything

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.