specifying MaxHttpCollectionKeys for a specific page?

时间秒杀一切 提交于 2019-12-19 20:41:12

问题


I am wondering if there is a way to change this value for a particular page, instead of setting it for the entire project. We are running into the limit, but only for a couple pages. Our project is using .NET 3.5.

For those who are unaware of what this variable is for, it is to get around this: http://support.microsoft.com/kb/2661403

Essentially if you have a lot of form keys (over 1000), you will get an exception when posting back to the page. You can get around this by specifying in your web.config:

There have been several questions about this limitation, such as this one: 'Operation is not valid due to the current state of the object' error during postback

However, I have not seen anything related to setting this for a specific page.


回答1:


No, that's not possible. It always checks the appSetting aspnet:MaxHttpCollectionKeys and if that is missing it will be set to 1000. You cannot override this because the reading of the setting and the default value is done inside an internal class.

Perhaps a better approach would be to build a form with less than 1000 items. Maybe in the form of a wizard. Or maybe by combining multiple values into a single data structure and deserializing it on the server.



来源:https://stackoverflow.com/questions/10325558/specifying-maxhttpcollectionkeys-for-a-specific-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!