Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Navigating a web form

Navigating a web form

Scheduled Pinned Locked Moved C#
comhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brsecu
    wrote on last edited by
    #1

    I'm trying to fill in a text box then hit the submit button using httpwebrequest. Here is a sample using googles home page(just because everyone can use it). I just cant seem to get it to work. Thanks for the help. string Uri = "http://www.google.com"; string requestString = "q=test&btnG=Clicked"; byte[] requestData = Encoding.UTF8.GetBytes(requestString); HttpWebRequest request = null; Stream stream = null; HttpWebResponse response = null; // set up request CookieContainer _cookies = new CookieContainer(); request = (HttpWebRequest)WebRequest.Create(Uri); request.Proxy = null; request.CookieContainer = _cookies; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = requestData.Length; // make form post stream = request.GetRequestStream(); stream.Write(requestData, 0, requestData.Length); // get response response = (HttpWebResponse)request.GetResponse();

    D 1 Reply Last reply
    0
    • B brsecu

      I'm trying to fill in a text box then hit the submit button using httpwebrequest. Here is a sample using googles home page(just because everyone can use it). I just cant seem to get it to work. Thanks for the help. string Uri = "http://www.google.com"; string requestString = "q=test&btnG=Clicked"; byte[] requestData = Encoding.UTF8.GetBytes(requestString); HttpWebRequest request = null; Stream stream = null; HttpWebResponse response = null; // set up request CookieContainer _cookies = new CookieContainer(); request = (HttpWebRequest)WebRequest.Create(Uri); request.Proxy = null; request.CookieContainer = _cookies; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = requestData.Length; // make form post stream = request.GetRequestStream(); stream.Write(requestData, 0, requestData.Length); // get response response = (HttpWebResponse)request.GetResponse();

      D Offline
      D Offline
      DotNetXenon
      wrote on last edited by
      #2

      Where exactly do you get the error?

      ------------------------------------------------------------ "The only true wisdom is in knowing you know nothing." --Socrates

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups