首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • Web页面如何接受客户端POST数据?急!在线等。 [已结帖,结帖人:juve1897]
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • juve1897
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    • 结帖率:
    发表于:2008-07-05 21:41:57 楼主
    以下是客户端vc发送post数据代码   
        CString strHttpName="http://localhost/TestReg/RegForm.aspx"; // 需要提交数据的页面
        CString strFormData = "?????";    // 需要提交的数据

        CInternetSession sess;
        CHttpFile* fileGet;
        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 = "";
        if(fileGet)
        {
            DWORD dwStatus;
            DWORD dwBuffLen = sizeof(dwStatus);
            BOOL bSuccess = fileGet->QueryInfo(HTTP_QUERY_STATUS_CODE &brvbarHTTP_QUERY_FLAG_NUMBER, &dwStatus, &dwBuffLen);
            if( bSuccess && dwStatus>= 200 &&dwStatus <300 )
            {
                BOOL result = fileGet->SendRequest(strHeaders, (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
                while(fileGet->ReadString(strSentence))    // 读取提交数据后的返回结果
                {
                    strGetSentence = strGetSentence + strSentence + char(13) + char(10);
                }
                AfxMessageBox(strGetSentence); // 显示返回网页内容
            }
            else
            {
                strSentence.Format("POST出错,错误码:%d", dwStatus);
                AfxMessageBox(strSentence);
            }
         
            fileGet->Close();
            delete fileGet;
        }
        else
            AfxMessageBox("不能找到网页文件!");

        sess.Close();


    服务器端如何用asp实现接受提交的数据strFormData?
    100  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • java2000_net_test
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-05 21:42:001楼 得分:0
    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【juve1897】截止到2008-07-05 21:41:55的历史汇总数据(不包括此帖):
    发帖的总数量:2                        发帖的总分数:70                     
    结贴的总数量:0                        结贴的总分数:0                       
    无满意结贴数:0                        无满意结贴分:0                       
    未结的帖子数:2                        未结的总分数:70                     
    结贴的百分比:0.00  %              结分的百分比:0.00  %                 
    无满意结贴率:---------------------无满意结分率:---------------------
    如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • mrshelly
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    • 2

    发表于:2008-07-05 22:17:492楼 得分:20
    ASP 端使用上传表单处理类来处理就行了.
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • ly8199
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-05 22:36:163楼 得分:0
    引用 2 楼 mrshelly 的回复:
    ASP 端使用上传表单处理类来处理就行了.
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • ly8199
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-05 22:36:434楼 得分:0
    引用 2 楼 mrshelly 的回复:
    ASP 端使用上传表单处理类来处理就行了.
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • Flow_Cloud
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-05 22:57:375楼 得分:0
    不了解,
    关注
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • ccssddnnhelp
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-05 23:13:016楼 得分:50
    request.form("yourID").
       
    ==== ====

    .
    贴子分数 <20:对自已的问题不予重视。
    贴子大量未结:对别人的回答不予尊重。
    .
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • ccssddnnhelp
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-05 23:14:577楼 得分:30
    以下摘自 Microsoft Help

    Request.Form Collection 


    The Form collection retrieves the values of form elements posted to the HTTP request body, with a form using the POST method.

    Form input is contained in headers. It is wise to not trust the data that is contained in headers, as this information can be falsified by malicious users. For example, do not rely on data such as cookies to securely identify a user.

    As a security precaution, always encode header data or user input before using it. A general method of encoding data is to use Server.HTMLEncode. Alternatively, you can validate header data and user input with a short function such as the one described in Validating User Input to Avoid Attacks. For more detailed information about developing secure Web applications, see chapter 12 of MS Press - Writing Secure Code.

    Syntax
    Request.Form( element )[(index)|.Count]

    Parameters
    element


    The name of the form element from which the collection is to retrieve values.
    index


    An optional parameter that enables you to access one of multiple values for a parameter. It can be any integer in the range 1 to Request.Form(parameter).Count.
    Applies To
    Request Object

    Remarks
    The Form collection is indexed by the names of the parameters in the request body. The value of Request.Form(element) is an array of all the values of element that occur in the request body. You can determine the number of values of a parameter by calling Request.Form(element).Count. If a parameter does not have multiple values associated with it, the count is 1. If the parameter is not found, the count is 0.

    To reference a single value of a form element that has multiple values, you must specify a value for the index parameter. The index parameter may be any number between 1 and Request.Form(element).Count. If you reference one of multiple form parameters without specifying a value for index, the data is returned as a comma-delimited string.

    When you use parameters with Request.Form, the Web server parses the HTTP request body and returns the specified data. If your application requires unparsed data from the form, you can access it by calling Request.Form without any parameters.

    Note: 
    When using ASP and posting large amounts of data more than 100 KB, Request.Form cannot be used. If your application requires posting data greater than this limit, a component can be written that uses the Request.BinaryRead method.



    You can iterate through all the data values in a form request. For example, if a user filled out a form by specifying two values, Chocolate and Butterscotch, for the FavoriteFlavor element, you could retrieve those values by using the following script.

    Visual Basic Script  Copy Code
    <%  For i = 1 To Request.Form("FavoriteFlavor").Count    Response.Write Request.Form("FavoriteFlavor")(i) & " <BR>"  Next %>


    The preceding script would display the following.

      Copy Code
    Chocolate Butterscotch


    You can use this technique to display the parameter name, as shown in the following script:

    Visual Basic Script  Copy Code
    <%    For i = 1 to Request.Form("FavoriteFlavor").count %>    Request.Form(FavoriteFlavor) = <%= Request.Form("FavoriteFlavor")(i)_    %> <BR> <% Next %>


    This script displays the following in the browser.

      Copy Code
    Request.Form(FavoriteFlavor) = Chocolate Request.Form(FavoriteFlavor) = Butterscotch


    Example Code
    Consider the following HTML form:

      Copy Code
    <FORM ACTION = "/scripts/submit.asp" METHOD = "post"> <P>Your first name: <INPUT NAME = "firstname" SIZE = 48> <P>What is your favorite ice cream flavor: <SELECT NAME = "flavor"> <OPTION>Vanilla  <OPTION>Strawberry  <OPTION>Chocolate  <OPTION>Rocky Road </SELECT> <P> <INPUT TYPE = SUBMIT> </FORM>


    Note: 
    If your form includes multiple objects with the same name (for example, HTML SELECT tags), the item in the form collection will be a comma-delimited list of all the selected values.



    From that form, the following request body could be sent:

      Copy Code
    firstname=James&flavor=Rocky+Road


    The following script can then be used:

    Visual Basic Script  Copy Code
    Welcome, <%= Request.Form("firstname") %>. Your favorite flavor is <%= Request.Form("flavor") %>.


    The following output is the result:

      Copy Code
    Welcome, James. Your favorite flavor is Rocky Road.


    Caution: 
    In the example above, the user's input is echoed without validation, which could pose a security risk.



    For more information, see MS Press - Writing Secure Code

    If the following script is used:

    Visual Basic Script  Copy Code
    The unparsed form data is:  <%= Request.Form %>


    The output would be:

      Copy Code
    The unparsed form data is:  firstname=James&flavor=Rocky+Road


    Requirements
    Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.

    Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

    Product: IIS

    See Also
    Reference
    Request.ClientCertificate Collection
    Request.Cookies Collection
    Request.QueryString Collection
    Request.ServerVariables Collection

    Concepts
    .
       
    ==== ====

    .
    贴子分数 <20:对自已的问题不予重视。
    贴子大量未结:对别人的回答不予尊重。
    .
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • luxu001207
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-05 23:39:558楼 得分:0
    表单用服务器控件的话,直接用"控件ID.Text"即可得到客户端post来的值,如果不是服务器控件,则可以使用Request.Form["表单名"]获取
    也可以使用Request.Params["表单名"]来获取
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • luxu001207
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-05 23:42:239楼 得分:0
    晕,看错了...
    没仔细看楼主的问题,我有罪...
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • good3g
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-06 02:15:1810楼 得分:0
    接受页要给个ID值
    一般
    *id=TRim(Request("*id"))
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • juve1897
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-06 06:52:0111楼 得分:0
    我没有使用表单,如何接受数据?
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • Anlige
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-06 07:04:3412楼 得分:0
    那你试怎么传递的参数?xmlhttp?post?还是get?
                  ----------------------------^_^大家一起学习^_^------------------------------
                  ASP学习博客 http://blog.ii-home.cn
                 
                  Email:zhanghuiguoanlige@126.com  QQ:417833272
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • juve1897
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-06 07:39:4413楼 得分:0
    Anlige,看一下源代码,就清楚了




    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • neo_yoho
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-06 10:06:4814楼 得分:0
    没接触过啊 试试改CString strFormData="xxx=value"
    asp用request.queryString("xxx")获取
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • cuidenghong123
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-07-06 23:16:2915楼 得分:0
    表单 或者 JS
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
    世纪乐知(北京)网络技术有限公司 提供技术支持
    Copyright © 2000-2008, CSDN.NET, All Rights Reserved