Solved

CWebControl PostData

Posted on 1998-07-28
2
369 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…

696 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