我有一个发布相当大数据的表单,但出现此错误
[InvalidOperationException: Operation is not valid due to the current state of the object.]
System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +2419334
System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +58
System.Web.HttpRequest.FillInFormCollection() +159
[HttpException (0x80004005): The URL-encoded form data is not valid.]
System.Web.HttpRequest.FillInFormCollection() +217
System.Web.HttpRequest.get_Form() +104
System.Web.HttpRequest.get_HasForm() +9035903
System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +97
System.Web.UI.Page.DeterminePostBackMode() +69
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +135
为了解决这个问题,我得到了这个解决方案来自 StackOverflow https://stackoverflow.com/questions/8978929/asp-error-operation-is-not-valid-due-to-the-current-state-of-the-object itself
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="2000" />
</appSettings>
现在我想知道可以设置的最大有效值aspnet:MaxHttpCollectionKeys
。把这个键设置为最大值有什么问题吗?
您可以在中看到 MaxHttpCollectionKeys 的实现aspnetwebstack 源 https://github.com/mono/aspnetwebstack/blob/master/src/System.Net.Http.Formatting/Formatting/MediaTypeFormatter.cs在 GitHub 上。
从实现来看,这些似乎是限制:
- MaxHttpCollectionKeys 是一个 int,因此它可以具有整数的最大值 (int.MaxValue: 2,147,483,647)
- 最小值为 1
- 默认值为 1000
This MSDN page https://msdn.microsoft.com/en-us/library/hh975440(v=vs.120).aspx recommends to not set MaxHttpCollectionKeys to a value too large as that would pose a security risk.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)