简体   繁体   中英

MVC Controller is being immediately disposed of

I have a page for a site in production that lists every Store in a Shopping Center. This allows the District Managers to detect changes to the tenancy of the Center.

One of the Shopping Centers has 107 stores in it, and the DM was receiving a weird error that is not the MVC Error Page every time he tries to save his process at this one Center (the dreaded "Server Error in '/' Application.").

I am walking through the code in the Debugger, and on the form submission for the page, the Controller's Constructor gets called, and as soon as it finishes out the Constructor, it goes immediately to the Dispose method. Any other version of the page (with a different Shopping Center) I've gone to goes from the Constructor to the requested Controller Method.

I've gone in the Web.config and changed the maxRequestLength to 8192, the maxQueryStringLength to 4096, and even the maxUrlLength to 1040 in the thought that perhaps the data being sent back on form submission was too large, but everything is still giving the same error.

I can provide some code if needed, but like I said it's not getting to the requested method, it goes directly from the Constructor to the Dispose method. I've checked the Call stack when it enters Dispose, but everything is listed as [External Code].

Per George Stocker's suggestion, I found the following in the Event Viewer:

Exception information:

Exception type: InvalidOperationException Exception message: Operation is not valid due to the current state of the object. at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) at System.Web.HttpRequest.FillInFormCollection()

When I took a look at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded(), I found this thread which explains how to rectify that. Making their suggested change, I was able to submit the form with no problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM