post 大量的資料

rusli
Site Admin
文章: 212
註冊時間: 週三 7月 07, 2010 9:49 pm

post 大量的資料

文章rusli » 週二 6月 05, 2012 3:04 pm

代碼: 選擇全部

    $.ajax({
                url: '<%=Url.Action("CustomerImport", "Api", new { area = "Mobile" })%>',
                type: "POST",
                data: '可裡面內容超出一定的大小',
                contentType: "multipart/form-data",
                enctype: "multipart/form-data",
                encoding: "multipart/form-data",
                dataType: "text",
                success: function (data) {
                       // 略
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    var errStr = xhr.status + ':' + xhr.responseText + thrownError;
                }
            });



server 怎麼接?

代碼: 選擇全部

 
        [HttpPost]
        public ActionResult CustomerImport()
        {
            string data = new StreamReader(Request.InputStream).ReadToEnd();
            if (string.IsNullOrEmpty(data))
            {
                return new ObjectResult<Result[]>(new[] { new Result(2, "FAIL") });
            }
            //// LogManager.ApplicationLogger.Info("Content:" + data);
            MobileContacts[] contacts = JSON.Helper.JsonToObject<MobileContacts>(data);
       
          //// 略
        }

回到「MVC」

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客