Web Analytics Made Easy -
StatCounter Opening Internet Explorer From C# - CodingForum

Announcement

Collapse
No announcement yet.

Opening Internet Explorer From C#

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Opening Internet Explorer From C#

    I am looking to open up a new internet explorer window and navigate to the URL of my choice when a user clicks a button. Seems simple enough but the only catch is that I need to send along POST data with that request. Does anyone know how to do this programmatically with C#? Thanks in advance.

  • #2
    Hi,

    Check out httprequest:
    http://www.google.com/search?q=c%23+...S%3Aofficial_s

    Post back if you run into any snags.

    Good luck;
    -Brando
    Why using tables for eating is stupid!

    Comment


    • #3
      I found a way to do exactly what I want. Here is the code if anyone is interested:

      Code:
      SHDocVw.InternetExplorerClass ie=new SHDocVw.InternetExplorerClass ();
       
      Object vHeaders = "Content-Type: application/x-www-form-urlencoded" + "\n" + "\r";
      Object vPost = null;
      Object vTarget = null;
      Object vFlags = null;
       
      string postData = "postvariable1=one&postvariable2=two";
      vPost = System.Text.ASCIIEncoding.ASCII.GetBytes(postData);
      ie.Navigate(http://url/,ref vFlags,ref vTarget,ref vPost,ref
      vHeaders);
      ie.Visible =true; 
      You also need to add a reference to Internet Explorer Controls 1.1 in solution explorer (under COM).

      That's all there is to it!

      Comment


      • #4
        paulq when i used the your code i get a this error message

        from IClassFactory (-0000-0000-C000-000000000046) 0002DF01 with CLSID of the COM component instance creation process failed with the following error: 80004005.

        can anyone help me how can i pass this error ?

        Comment

        Working...
        X