Solved

CWebControl PostData

Posted on 1998-07-28
2
361 Views
Last Modified: 2013-11-20
I'm using the following code in a VC++5.0(no patches applied), IE4.01
configuration and postData is not working.  The web browser control
navigates to the url I give it, but it's method is GET and it doesn't send
my postData.  When PostData is not NULL it's supposed to send a
request method of POST and send the data.

Also I sent a breakpoint in BeforeNavigate2() and read the PostData string
it's empty!

Here is the code snippet from my app.

void CMyView::SetNavigationLocation(CString url, CString postData)
{
    //    url = "http://www.ecst.csuchico.edu/~jschlich/Flyfish/fishinfotest.cgi";
   //    postData = "userid=tim_z&pass=dont_you_wish";

    CString header;
    // Content-Type: application/x-www-form-urlencoded\r\n
    header.LoadString(IDS_FORM_URLENCODED);

    COleVariant oleVariant;
    COleVariant urlOleVariant( url );
    COleVariant dataOleVariant( postData );
    COleVariant headerOleVariant( header );

    m_WebBrowser.Navigate2(&urlOleVariant, &oleVariant, &oleVariant, &dataOleVariant, &headerOleVariant);
}

This problem has got me at a complete stand still.  If anyone can help, I will be very
very grateful and acknowledge you as the MFC WebBrowser guru!

Jeff
0
Comment
Question by:NotJeff
2 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 210 total points
Comment Utility
The post data specified by PostData is passed as a SAFEARRAY structure. The variant should be of type VT_ARRAY and point to a SAFEARRAY. The SAFEARRAY should be of element type VT_UI1, dimension one, and have an element count equal to the number of bytes of post data. Instead of

COleVariant dataOleVariant(postData);

do the following,

COleSafeArray saPostData;
if (!postData.IsEmpty())
    saPostData.CreateOneDim(VT_UI1, postData.GetLength(), (LPCTSTR)postData);
0
 

Author Comment

by:NotJeff
Comment Utility
I hereby hail chensu as the web control master!  And at the same time I'd like to poop on Microsofts documentation of this function.  Everything works great now!  Send me an email at the root url in my sample and I'll buy you lunch.  Thanks  NotJeff
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now