zoukankan      html  css  js  c++  java
  • HttpWebResponse Post 前端控件数据,后台如何接收?

    MVC视图页:

    @{
        Layout = null;
    }
    
    <!DOCTYPE html>
    
    <html>
    <head>
        <title>test</title>
         <script src="/Content/js/jquery-1.10.2.min.js?v=2018071901" type="text/javascript"></script>
    </head>
    <body>
    <form id="frSubmitOrder" action="" method="post">
    <input id="O_LeagueID" name="O_LeagueID" type="hidden" value="1111" />
            <input id="O_Product_ID" name="O_Product_ID" type="hidden" value="2222" />
            <input id="O_HotelID" name="O_HotelID" type="hidden" value="3333" />
            <input id="O_RoomTypeID" name="O_RoomTypeID" type="hidden" value="4444" />
            <input id="O_RoomID" name="O_RoomID" type="hidden" value="5555" />
            <input id="appid" name="appid" type="hidden" value="6666" />
            <input id="ctoken" name="ctoken" type="hidden" value="77777" />
    
       <div class="submit-order-btn clickable red-btn color3" data-name="预订-提交订单">
                提交订单
            </div>
    
     </form>
     <script type="text/javascript">
         $(function () {
             //搜索 点击搜索
             $(".submit-order-btn").click(function () {
                 $('#frSubmitOrder').submit();
             });
         });
    </script>
    </body>
    </html>

    mvc控制器:

            [HttpPost]
            public ActionResult test(string id)
            {
                Dictionary<string, string> dict = new Dictionary<string, string>();
                dict.Add("action", "Add");
                //Response.Write("<li>" + Request.Params.Keys[i].ToString() + " = " + Request.Params[i].ToString());
                for (int i = 0; i < Request.Form.Count; i++)
                {
                    dict.Add(Request.Form.Keys[i].ToString(), Request.Form[i].ToString());
                }
                return Json(Post("http://localhost:57239/Ajax/Order.ashx", dict), JsonRequestBehavior.AllowGet);
            }
    Order.ashx 接收post 来的数据:
            string _action = context.Request["action"];
            string appid = context.Request["appid"];
           
    
            if (context.Request.RequestType == "POST")
            {
                //接收并读取POST过来的XML文件流
                StreamReader reader = new StreamReader(context.Request.InputStream);
                String xmlData = reader.ReadToEnd();
            }


  • 相关阅读:
    C++中的头文件和源文件
    串口VMIN VTIME 详解
    lms111,rplidar 方向和起始角
    Nginx访问限制配置
    Nginx请求限制配置
    Nginx模块详解
    Nginx默认配置语法
    Nginx编译参数详解
    Nginx安装目录详解
    Nginx的快速安装
  • 原文地址:https://www.cnblogs.com/Fooo/p/9428289.html
Copyright © 2011-2022 走看看