c# – Asp.NET Erro Click do Asp:button


I have a screen where I have some buttons and clicking on the buttons gives me the error on the screen:

"Index was out of Range Must be non-negative and less than the size of the collection."

The strangest thing is that in the click event of these buttons there is a try/catch , and inside the catch a method that logs errors that occurred in the system.

In short: the button's "Click" event is not being entered..

To make things more difficult, the error only occurs in production, not in development… and I have no way to access the production environment.

Doing some tests here I found that if I access the system page using "https" the buttons work normally, with the "http" this error "index was out…". This error has started to occur since the last rise in production.


The error is typical of trying to access some position of the Array with a negative index.

If the event does not arrive on click, it is because before executing the Click event, in the Page flow, the Page_Load event is always executed. So there might be some code in this event that is causing the error.

If you post your code, we can resolve it more accurately.

Scroll to Top