aspnet的最大值:MaxHttpCollectionKeys

时间:2012-11-09 10:44:30

标签: asp.net

我有一个发布相当大数据的表单,我收到此错误

[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

要解决此问题,我自己this solution from StackOverflow

<appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="2000" />
</appSettings>

现在我想知道可以为aspnet:MaxHttpCollectionKeys设置的最大有效值。将此键设置为最大值是否有任何问题?

1 个答案:

答案 0 :(得分:7)

您可以在GitHub上的aspnetwebstack source中看到MaxHttpCollectionKeys的实现。

从实施情况来看,这似乎是限制:

  1. MaxHttpCollectionKeys是一个int,所以它可以有一个整数的最大值( int.MaxValue:2,147,483,647
  2. 最小值为1
  3. 默认值为1000
  4. MSDN page建议不要将MaxHttpCollectionKeys设置为太大,因为这会造成安全风险。 enter image description here

相关问题