【发布时间】:2016-10-25 20:56:30
【问题描述】:
我们的应用程序使用 AngularJS -> MVC-> WebAPI-> EF 架构。 从 Angularjs 上传时,它曾经通过在 web.config 中设置以下内容来处理 50K 记录
<httpRuntime targetFramework="4.5" maxRequestLength="100000" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="300000000" />
</requestFiltering>
</security>
MVCController.cs
var serializer = new JavaScriptSerializer();
serializer.MaxJsonLength = Int32.MaxValue;
var CBListData = serializer.Serialize(CBList);
HttpResponseMessage response = await httpClient.PostAsJsonAsync(
"api/PostCLIENTValues", JArray.Parse(CBListData));
但是我需要上传一个包含 1 或 150 万条记录的 excel 文件,上述代码无法序列化并作为 json 传递。它抛出错误
"cannot evaluate the expression"
这里有什么可行的方法? 我可以直接从 angularJS 发送到 webAPI 还是有任何解决方法可以从 MVC->WebAPI
发送【问题讨论】:
-
“以上代码序列化失败”?它是如何失败的?错误?
-
为什么在客户端需要 1kk 记录?使用分页或某种过滤器来减少记录量
-
@spender 是的,它失败了 150 万条记录。
-
@teovankot 正在向 webapi 发送 150 万条记录以插入到数据库中。就像我在这里做批量插入一样
-
您的文件较大,您可能只需要增加最大长度值。您为什么不查看 excel 文件的大小,并将其用作这些属性的指南?
标签: c# asp.net-mvc asp.net-web-api asp.net-mvc-5