felixmosesj
asked on
Problem in using AxWebBrowser component in C# application
I have a C# windows application form which embeds a AxWebBrowser component in it.
I specified the html file URL(a.html) in the navigate method of the component.
In the body onload method of the a.html I have a automatic redirect to some other html file(b.html).
Now I want to capture the text or the html of the redirected html file(b.html) . I cannot specify this file name(b.html) in the navigate method as I have to pass some parameters from the first file so I can specify only the first file name(a.html) in the navigate method of the AxWebBrowser component.
I did try with the following code. I try to use the navigate event of the AxWebBrowser component
private void axWebBrowser1_NavigateComp lete2(obje ct sender, AxSHDocVw.DWebBrowserEvent s2_Navigat eComplete2 Event e)
{
doc = (mshtml.IHTMLDocument2)axW ebBrowser1 .Document;
MessageBox.Show(doc.body.i nnerText.T oString()) ;
}
The above method is retrieving only the contents of the a.html. Is there a way to retrieve the contents of the b.html without actually specifying the url of b.html file in the navigate method.
Or is there a way in C# to use the HTTPWebResponse related objects to accomplish the above scenario(Get the contents of the second html file automatically).
Somebody please help in this.
I specified the html file URL(a.html) in the navigate method of the component.
In the body onload method of the a.html I have a automatic redirect to some other html file(b.html).
Now I want to capture the text or the html of the redirected html file(b.html) . I cannot specify this file name(b.html) in the navigate method as I have to pass some parameters from the first file so I can specify only the first file name(a.html) in the navigate method of the AxWebBrowser component.
I did try with the following code. I try to use the navigate event of the AxWebBrowser component
private void axWebBrowser1_NavigateComp
{
doc = (mshtml.IHTMLDocument2)axW
MessageBox.Show(doc.body.i
}
The above method is retrieving only the contents of the a.html. Is there a way to retrieve the contents of the b.html without actually specifying the url of b.html file in the navigate method.
Or is there a way in C# to use the HTTPWebResponse related objects to accomplish the above scenario(Get the contents of the second html file automatically).
Somebody please help in this.
ASKER
Andy,
It is not refresh tag and I am not sure about the 302 redirect. The code in the a.html file is this
function postForm()
{
document.Form1.submit();
}
<body onload="postForm();" MS_POSITIONING="GridLayout ">
<form id="Form1" name="Form1" method="post" action="https://localhost/b.html" language="javascript" id="Form1">
Some important Statements Here
</form>
</body>
Now I want to get the response of the b.html file. Directly I should not get the response of the b.html. First my a.html file should load and then it gets automatically redirected to b.html and finally I should get the text or html content of b.html file. If possible please post a sample code.
It is not refresh tag and I am not sure about the 302 redirect. The code in the a.html file is this
function postForm()
{
document.Form1.submit();
}
<body onload="postForm();" MS_POSITIONING="GridLayout
<form id="Form1" name="Form1" method="post" action="https://localhost/b.html" language="javascript" id="Form1">
Some important Statements Here
</form>
</body>
Now I want to get the response of the b.html file. Directly I should not get the response of the b.html. First my a.html file should load and then it gets automatically redirected to b.html and finally I should get the text or html content of b.html file. If possible please post a sample code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Andy