• 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();
            }


  • 相关阅读:
    MySQL DDL 在指定位置新增字段
    .NET平台常见技术框架整理汇总
    使用Linq求和方法Sum计算集合中多个元素和时应该注意的性能问题
    python时间操作
    django 利用原生sql操作数据库
    滑动验证码获取像素偏移量
    python opencv简单使用
    django通过旧数据库库生成models
    pandas 操作csv文件
    简单工厂模式(Simple Factory Pattern)
  • 原文地址:https://www.cnblogs.com/Fooo/p/9428289.html
Copyright © 2020-2023  润新知