/// <summary> /// Web Browser POST request. /// </summary> /// <param name="url"> URL to query.</param> /// <param name="postData"> Post Data in bytes.</param> /// <param name="cookies"> Cookie collection.</param> /// <param name="inspectorAction"> Inspector Action. </param> public void PostForm(string url, byte[] postData, CookieCollection cookies, InspectorAction inspectorAction) { isLinkNavigation = false; inspectorState = inspectorAction; object flags = new Object(); object targetFrame = new Object(); object data = postData; object headers = "Content-Type: application/x-www-form-urlencoded" + "\n" + "\r";; this.web.Navigate(url,ref flags,ref targetFrame, ref data, ref headers); }
// Fires when the browser ActiveX control finishes loading a document private void OnComplete(IHTMLDocument2 htmlDoc) { // Adds some event handlers to the DOM Document AddEventsToDoc(htmlDoc); formCollection = HtmlDomTransformation.TransformFormElements(htmlDoc, new Uri(htmlDoc.location.toString())); // FIX: This might be no longer neccesary because // it injects code into the document. //SetFormOnSubmit(htmlDoc); // check if it is NewWindow if ( isNewWindow ) { RequestGetEventArgs args = new RequestGetEventArgs(); args.Url = (string)web.LocationURL; args.InspectorRequestAction = InspectorAction.WebBrowserGet; this.StartEvent(this, args); isNewWindow = false; } // raise load links event if ( LoadLinksEvent != null ) { LoadLinksEventArgs args = new LoadLinksEventArgs(); args.Frames = HtmlDomTransformation.TransformFrameElements(htmlDoc); args.Anchors = HtmlDomTransformation.TransformAnchorElements(htmlDoc); args.Links = HtmlDomTransformation.TransformLinksElements(htmlDoc); LoadLinksEvent.BeginInvoke(this, args, new AsyncCallback(FireAndForget), null); } // raise load forms event if ( LoadFormsEditorEvent != null ) { // Transform form elements to HTML DOM Document. LoadFormsEditorEvent.BeginInvoke(this, new LoadFormsEditorEventArgs(postData, formCollection), new AsyncCallback(FireAndForget),null); } // reset inspectorState = InspectorAction.Idle; }
/// <summary> /// Web Browser GET Request. /// </summary> /// <param name="url"> URL to query.</param> /// <param name="cookies"> Cookie collection.</param> /// <param name="inspectorAction"> Inspector Action.</param> public void Navigate(string url, CookieCollection cookies, InspectorAction inspectorAction) { isLinkNavigation = false; inspectorState = inspectorAction; object flags = new Object(); object targetFrame = new Object(); object postData = new Object(); object headers = new Object(); this.web.Navigate(url,ref flags,ref targetFrame, ref postData, ref headers); }