Solved

CWebControl PostData

Posted on 1998-07-28
2
366 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
ID: 1319866
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
ID: 1319867
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 162
Complete beginner needs help making a cron job 9 117
either24  challenge 19 97
Use of condition with 'serial' in ansible 2 62
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…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 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