本文介绍了由于对象的当前状态,操作无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在c#中有一个asp.net网络应用程序,

我从excel表中获取数据并通过数据表将其填入转发器中。



这个excel表包含650行和20列。



它正在获取所有记录并填写转发器。



但是当我试图将这些数据推送到服务器时,

我收到此错误



由于对象的当前状态,操作无效。 

描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.InvalidOperationException:由于对象的当前状态,操作无效。

源错误:

在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。

堆栈跟踪:


[InvalidOperationException:由于对象的当前状态,操作无效。]
System.Web.HttpRequest。 FillInFormCollection()+9038554
System.Web.HttpRequest.get_Form()+ 104
System.Web.HttpRequest.get_HasForm()+ 9039071
System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull)+97
System.Web.UI.Page.DeterminePostBackMode()+ 69
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+135

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.272





i已经在互联网上搜索了这个错误,我得到了一些解决方案。



我试过的地方,



< appSettings> 
< add key =aspnet:MaxHttpCollectionKeysvalue =5000/>
< add key =aspnet:MaxJsonDeserializerMembersvalue =5000/>
< add key =FolderPathvalue =Files //>
< / appSettings>





我仍​​然遇到同样的错误。



任何人都可以帮助我。





谢谢

解决方案

Hi guys,

I have a asp.net web application in c#,
where i'm fetching data from excel sheet and filling this in a repeater via datatable.

This excel sheet contains 650 rows and 20 columns.

it is fetching all the records and filling the repeater also.

But when i'm trying to push this data to server,
i'm getting this Error

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.HttpRequest.FillInFormCollection() +9038554
   System.Web.HttpRequest.get_Form() +104
   System.Web.HttpRequest.get_HasForm() +9039071
   System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +97
   System.Web.UI.Page.DeterminePostBackMode() +69
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +135

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



i have searched on internet regarding this error n i got some solutions.

where i have tried,

<appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="5000" />
    <add key="aspnet:MaxJsonDeserializerMembers" value="5000" />
    <add key="FolderPath" value="Files/"/>
  </appSettings>



still i'm getting the same error.

Can anyone please help me.


Thanks

解决方案


这篇关于由于对象的当前状态,操作无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 01:36