首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ASP.NET MS11-100:如何更改发布的表单值的最大数量限制?value="10000000000“不工作

ASP.NET MS11-100:如何更改发布的表单值的最大数量限制?value="10000000000“不工作
EN

Stack Overflow用户
提问于 2012-04-06 01:17:34
回答 2查看 2.1K关注 0票数 0

我收到了这个错误消息。

代码语言:javascript
复制
Server Error in '/' Application.
Operation is not valid due to the current state of the object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Operation is not valid due to the current state of the object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: Operation is not valid due to the current state of the object.]
   System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +2420322
   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
   Microsoft.Web.Infrastructure.DynamicValidationHelper.<>c__DisplayClass8.<MakeCollectionsLazy>b__2() +12
   Microsoft.Web.Infrastructure.DynamicValidationHelper.<>c__DisplayClass12.<ReplaceCollection>b__e() +61
   Microsoft.Web.Infrastructure.DynamicValidationHelper.<>c__DisplayClass12.<ReplaceCollection>b__11() +17
   Microsoft.Web.Infrastructure.DynamicValidationHelper.DeferredCountArrayList.get_Count() +17
   System.Collections.Specialized.NameObjectCollectionBase.get_Count() +15
   System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, RequestValidationSource requestCollection) +23
   System.Web.HttpRequest.get_Form() +150
   System.Web.HttpRequestWrapper.get_Form() +11
   System.Web.Mvc.HttpRequestExtensions.GetHttpMethodOverride(HttpRequestBase request) +126
   System.Web.Mvc.AcceptVerbsAttribute.IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) +41
   System.Web.Mvc.HttpGetAttribute.IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) +40
   System.Web.Mvc.<>c__DisplayClass11.<RunSelectionFilters>b__d(ActionMethodSelectorAttribute attr) +24
   System.Linq.Enumerable.All(IEnumerable`1 source, Func`2 predicate) +145
   System.Web.Mvc.ActionMethodSelector.RunSelectionFilters(ControllerContext controllerContext, List`1 methodInfos) +319
   System.Web.Mvc.ActionMethodSelector.FindActionMethod(ControllerContext controllerContext, String actionName) +59
   System.Web.Mvc.ReflectedControllerDescriptor.FindAction(ControllerContext controllerContext, String actionName) +62
   System.Web.Mvc.ControllerActionInvoker.FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, String actionName) +16
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +105
   System.Web.Mvc.Controller.ExecuteCore() +116
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969201
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 

我已经试着做了建议的修复

代码语言:javascript
复制
<appSettings>
   <add key="aspnet:MaxHttpCollectionKeys" value="1001" />
</appSettings>

我试着把它放在一个疯狂的数字上

代码语言:javascript
复制
<add key="aspnet:MaxHttpCollectionKeys" value="10000000000" />

然而,它仍然给我同样的错误(我有很多字段,但没有那么多)。我使用的是asp.net MVC3(剃刀)。我使用的是.net 4.0。

我通过jquery ajax(seralizeArrary)发送了整个表单,所以我不知道这是否与它有关。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-04-06 17:37:46

使用一个更合理的值,比如32000,这对我来说很好。

有没有办法把它限制在允许它的形式上,而不是像现在看起来那样是全局的?

不,我不认为这是可能的处理每个表单的这个设置。这是因为这些值在路由发生之前就会被解析,但只有在路由之后才会知道这属于什么“形式”。

票数 0
EN

Stack Overflow用户

发布于 2015-12-02 14:31:32

限制如下:

  1. MaxHttpCollectionKeys是一个整数,因此它的最大值可以是一个整数( 2,147,483,647)
  2. Minimum int.MaxValue is 1
  3. 默认值是1000

Check on MSDN

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10033039

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档