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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:41:29+00:00 2026-05-28T07:41:29+00:00

I want to navigate to a website using pre-defined cookies, Add some text to

  • 0

I want to navigate to a website using pre-defined cookies,
Add some text to couple of input type="text" and submit the form using the submit button.
I know it can be done, but I can’t find how.

I already tried to send the POST data to the page, but I have to click the button for the action to be executed.
Here is my code:

        static String readHtmlPage(string url)
        {

        //setup some variables

        String username = "demo";
        String password = "password";
        String firstname = "John";
        String lastname = "Smith";

        //setup some variables end

        String result = "";
        String strPost = "username=" + username + "&password=" + password + "&firstname=" + firstname + "&lastname=" + lastname;
        StreamWriter myWriter = null;

        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
        objRequest.Headers["Cookie"] = "sid=0";
        objRequest.Headers["Cookie"] = "username=0";
        objRequest.Method = "POST";
        objRequest.ContentLength = strPost.Length;
        objRequest.ContentType = "application/x-www-form-urlencoded";

        try
        {
            myWriter = new StreamWriter(objRequest.GetRequestStream());
            myWriter.Write(strPost);
        }
        catch (Exception e)
        {
            return e.Message;
        }
        finally
        {
            myWriter.Close();
        }

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
        using (StreamReader sr =
           new StreamReader(objResponse.GetResponseStream()))
        {
            result = sr.ReadToEnd();

            // Close and clean up the StreamReader
            sr.Close();
        }
        return result;
    }


    static void Main(string[] args)
    {

        Console.Write(readHtmlPage("http://www.ggogle.com/"));
    }
  • 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-28T07:41:30+00:00Added an answer on May 28, 2026 at 7:41 am

    My suggestion, which I’ve done in the past is to:
    – Use Fiddler and hit the site with your browser and fill out the form like you would normally.
    – Fiddler will record the request/response and you can copy the post data string and replace any values you need there and use HttpWebRequest/HttpWebResponse to programmatically do the POST and get the response.

    post data through httpWebRequest

    Example: Here is the post data I captured when I submitted the last comment.

    comment=When+you+collect+the+recorded+POST+string+you+can+swap+out+the+key+value+pairs+in+there+before+you+make+the+request.+When+the+OnClick+event+fires+it+will+POST+data+to+the+server%2C+this+is+what+you+need+to+recreate+nothing+with+the+javascript.&fkey=62a7d57a52ee7fa723413a2e1dbe7e71

    string postData = string.format("comment={0}&fkey={1}", myCommentString, myFKey);
    

    You can then pass this string to the url that the POST was against and use HttpWebRequest to recreate it.

    You also need to make sure you are URL Encoding your values in the post string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I want to navigate directly to the second state of some flex app,
I want to conditionally navigate to some page. If some condition is true i
want to know why String behaves like value type while using ==. String s1
I want my anonymous user to be able to navigate throughout the website, but
I am using Coda-Slider for my website and I want to know if there
I have a design question. I'm using the HttpURLConnection class to navigate a website.
I want to navigate to the N-th level of an object, and serialize it's
I want to make a site where there user can basically navigate the web
When I use Emacs I want to be able to easily display and navigate
I am testing the security of my website. I am using the following URL

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.