CHtmlView navigate2 and post method

  • 11 years ago
    Hi to all,

    I want to send post data to some web page using CHtmlView and Navigate2 function.
    This code I am using now:

    void CnutritionresultsView::OnInitialUpdate()

    Navigate2(_T("http://localhost/wayneextrafunction/"),NULL,NULL );

    I want to send two post parametars to page http://localhost/wayneextrafunction/

    How can I do that.
    Best Regards,
  • 11 years ago

    In MSDN 2005, there are two prototypes that you can send your post data :

    void Navigate2(
       LPCTSTR lpszURL,
       DWORD dwFlags = 0,
       LPCTSTR lpszTargetFrameName = NULL,
       LPCTSTR lpszHeaders = NULL,
       LPVOID lpvPostData = NULL,
       DWORD dwPostDataLen = 0

    void Navigate2(
       LPCTSTR lpszURL,
       DWORD dwFlags,
       CByteArray& baPostedData,
       LPCTSTR lpszTargetFrameName = NULL,
       LPCTSTR lpszHeader = NULL

    In first one, the fifth parameter, and in second, the third parameter.

    Also, there are some infos :


    Data to send with the HTTP POST transaction. For example, the POST transaction is used to send data gathered by an HTML form. If this parameter does not specify any post data, Navigate2 issues an HTTP GET transaction. This parameter is ignored if URL is not an HTTP URL.


    Length in bytes of the data pointed to by the lpvPostData parameter.


    A reference to a CByteArray object.

  • 11 years ago

    Thanks Mohammad,

    I already solved the problem.

    This is code I am using:

    Navigate2(_T("http://localhost/wayneextrafunction/"), 0,0,_T("Content-Type: application/x-www-form-urlencoded"),"username=vas123&password=vas123&login=Enter+Here",sizeof("username=vas123&password=vas123&login=Enter+Here") );

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Walking on water and developing software from a specification are easy if both are frozen.” - Edward V Berard