2

I'm currently writing a c# window forms application, that starts an instance of the internet explorer, navigates to a certain intranet page, fills out a form and submits that form.

Here is some of the code:

int state = 0;

SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();
ie.DocumentComplete += ie_DocumentComplete;
ie.Visible = false;

string url = "http://xch:8080/intro/open/index.jsp";
ASCIIEncoding Encode = new ASCIIEncoding();
byte[] post = Encode.GetBytes("check=Agd3458HD3jhf");
string postHeaders = "Content-Type: application/x-www-form-urlencoded";
state = 1;
ie.Navigate2(url, null, null, post, postHeaders);

private void ie_DocumentComplete(object pDisp, ref object URL)
{
    if (state == 1)
    {
        //call a function that fills out the form, submits it and sets "state" to 2
    }
    else if (state == 2)
    {
        ie.Visible = true;
    }
}

This is basically it. But there seem to occur some major problems with the "xch" in the url. When i use the ip-address instead everything is fine. With "xch" something gets messed up:

  • The browser window already shows up on "ie.Navigate2(...)"
  • The DocumentComplete event handler is never reached
  • When i try to access the HTMLDocument or some Elements in it, an Exception is thrown

My client insists to have the "xch" in the address bar instead of the ip-address and my first thought was, that it wouldn't matter, because the browser can reach the page either way. But obviously i was wrong :/ I also should mention, that the problem doesn't always occur when i use "xch". So far it only occurs on Windows 7 PCs with IE9 and a user that doesn't have admin rights. So, my question would be if anyone else had similar issues and what can i do to narrow the problem?

Ron
  • 24,175
  • 8
  • 56
  • 97
basilikum
  • 10,378
  • 5
  • 45
  • 58
  • If you browse to the addresses through IE, which zone is each one in (Intranet, Internet, Trusted ...)? If they are in different zones, try setting up IE to force them into the same zone. – John Koerner Jun 20 '12 at 13:16
  • Use `http://xch/intro/open/index.jsp:8080` – Hans Passant Jun 20 '12 at 14:01
  • That was actually a good advice. It seems that it is in the zone Internet when i use the ip-address and in the zone Intranet when i use "xch". – basilikum Jun 20 '12 at 14:12
  • 1
    I got it: The problem was that in IE9 the protected mode for the Intranet zone is normally disabled and that apparently causes the SHDocVw stuff (which is afaik ActiveX?) to break down. – basilikum Jun 20 '12 at 14:24

0 Answers0