How to call HTML (with POST) page from Web form

M

McBeth

Hi!
I'm trying to call external HTML web page requiring several POST-ed
parameters from C# Web form. Parameters should be set by Web form. Is it
possible ? How can I do it ?

Thanks in advance

Adam
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

If you past the values in the querystring it will get as GET, not as POST

cheers,
 
B

Brett Romero

It will perform a POST and you can confirm that in the HTTP debugger
tool.

Brett
 
B

Brett Romero

Are you wanting to pre fill a form in the browser or just call the
browser's Navigate() method with your URL parameters included?

You'll need control of an IE instance (ShowDoc object) in either case.
If the first, you'll also need familiarity with MSHTML object. If the
latter, you only need to involve the Navigate() method of the instance
for the POST.

Brett
 
M

McBeth

Are you wanting to pre fill a form in the browser or just call the
browser's Navigate() method with your URL parameters included?
Just to call a window with parameters POST-ed
If the first, you'll also need familiarity with MSHTML object. If the
latter, you only need to involve the Navigate() method of the instance
for the POST.

Could you tell me where to look for an example ?

Thanks

Adam
 
B

Brett Romero

I'm not sure what you mean by the first statement. If the FORM has
been POSTed then you are only wanting to get the POST results from the
result page?

On the second question, this is a psuedo example of how to get it
going. I'm actually using a component from Clever Components for most
parsing. I find it to make those task easier and they have excellent
support.

//get things going by declaring the IE instance and referencing MSHTML
for document parsing
private SHDocVw.InternetExplorer IE_Inst = new
SHDocVw.InternetExplorerClass();
private mshtml.HTMLDocument ieDoc;

//use the following for getting at HTML in the document. Make use of
OuterHTML values you see in the debugger. This allows you to parse the
HTML.
mshtml.HTMLBody ieBody;
ieDoc = (mshtml.HTMLDocument)IE_Inst.Document;

//get information about the document body if you need to
ieBody = (mshtml.HTMLBody)ieDoc.body;
DocHeight = (double)ieBody.scrollHeight

//Just an example of doing a POST in the IE instance you've created
NavigateToWebPage(FormPostURL, formFieldString, vHeaders);

You can see I've wrapped the IE Navigate method just to check for null
strings and other validations. I'm also passing in my own Header
string. The actual Navigate uses two here. You'll need to do more
work to get it going but it should give you an idea of how things work.

Brett
 
M

McBeth

I'm not sure what you mean by the first statement. If the FORM has
been POSTed then you are only wanting to get the POST results from the
result page?

I'm really grateful fo your efforts to clarify this to such a dummie :) but
let me explain this again:
I code a Web Form in C#. I need to open remote HTML page, which requires
several parameters (using POST method). Now I know, I should use Navigate
method to open a new browser window with given URL, but it's still unclear
how I should pass parameters. I'd really appreciate if you could give me an
example.

Thanks
Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top