在网上找到很多关于CHttpFile的例子,
大致都是看到两个方法SendRequest()用来send数据给网站,
再用ReadString()读取信息。
但sendRequest发送出去的数据在asp.net网页上怎么接收??
readString()读回来的东西好象是网页的源代码,
怎样才能让网页上读到chttpfile传送过来数据,再进行处理后,
发回一段处理后的信息(比如"yes"或"no"),让chttpfile读回来。

解决方案 »

  1.   

    http流发送的本身就是页面, 必须包含http头和文件体
    http头包含charset,content-length,alive, cookie等等控制数据, 文件体才是你要的"数据"建议仔细阅读下http协议相关的资料
    -------------------------------------------------------
    广告:VC/WinAPI 网络/多线程讨论 QQ群, 群号:41356711
      

  2.   

    readString()读回来的东西好象是网页的源代码?????这下你发达了。
      

  3.   

    fantiyu说得我还是迷迷糊糊的。
    VC的源代码如下。asp.net里的接收应该怎么写啊?CString strHttpName= _T("http://localhost/GetMessage.aspx"); // 需要提交数据的页面
        CString strFormData = _T("nickname=abc");    // 需要提交的数据    CInternetSession sess; CHttpFile* fileGet;   //CHttpConnection* pConnection =
       //   sess.GetHttpConnection(strHttpName);   // CHttpFile* fileGet = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,_T("GetMessage.aspx"));
        CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded"); // 请求头    try
        {
            fileGet=(CHttpFile*)sess.OpenURL(strHttpName);//打开文件
        }
        catch(CException* e)
        {
            fileGet = 0;
            throw;
        }    CString strSentence, strGetSentence = _T("");
        if(fileGet)
        {
            DWORD dwStatus;
            DWORD dwBuffLen = sizeof(dwStatus);
            BOOL bSuccess = fileGet->QueryInfo(HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &dwStatus, &dwBuffLen);
            if( bSuccess && dwStatus>= 200 &&dwStatus<300 )
            {   
                BOOL result = fileGet->SendRequest(strHeaders, (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
    ShellExecute(NULL,NULL,strHttpName,NULL,NULL,SW_SHOWNORMAL);
                while(fileGet->ReadString(strSentence))    // 读取提交数据后的返回结果
                {
                    strGetSentence = strGetSentence + strSentence + char(13) + char(10);
                }
                AfxMessageBox(strGetSentence); // 显示返回网页内容
            }
            else 
            {
                strSentence.Format(_T("POST出错,错误码:%d"), dwStatus);
                AfxMessageBox(strSentence);
            }
            
            fileGet->Close();
            delete fileGet;
        }
        else
            AfxMessageBox(_T("不能找到网页文件!"));    sess.Close();
      

  4.   

    asp.net网页上怎么接收?? 
    readString()读回来的东西好象是网页的源代码,  

    貌似返回的是Response后的页面,
    asp.net的源代码真被你读到了, 那恭喜发财了..
    快散分吧!