ASP.Net MVC: "This key was not in the dictionary"

I have a set of websites created in MVC - each, in fact, is a clone of one source site). On one of the sites I get an error message from the header of this message ("this key is not in the dictionary") - this happens on only one page. The code is identical to all sites, including the one that operates. Each of the sites is installed with the same configuration (most of them are parallel to each other on the same server). I cannot replicate this in my Dev environment, so I don’t know how to debug (our sites are compiled using the Nant build process and all are configured in Release mode, so there is no information about debugging information).

When I look at the trace of the error stack, I notice that in no case does it call our code - these are all the calls on the ASP.Net page of the life cycle (in particular, the last significant function is the method called "__RenderSearchContent" in the Compiled page As far as I can tell from the processing of the corresponding controller action, there are no instances in which the code uses the Dictionary object.

It seems to me that I'm missing something, but I'm not sure where to look - the code does not seem to be a problem, there should not be any differences in the environment (although this is not impossible - the database, for example, is a different installation, but has an identical circuit and is not yet used for stack tracing).

In one area that I suspect there is routing that I know uses a dictionary - but, of course, if that were the case, would other sites suffer from the same problem?

Are there any suggestions as to where I can find the cause of this problem?

Any help would be greatly appreciated.

Greetings

+1
source share
2 answers

Ok, so the problem was not where I expected. If I had a dollar for every time it happened ...

Basically, the problem was found in the view that caused the error. There was a data item that was present on other websites, but not this one. I guess this type of problem is where strongly typed objects are ideal.

+2
source

Check if the request parameters (or forms) for the request that causes the problem contain the parameter (or parameters) corresponding to the controller argument names. When an action is invoked, it should look in the query parameters for named parameters corresponding to the names of the action arguments.

+1
source

Source: https://habr.com/ru/post/1401475/


All Articles