SaaS CMS has officially launched! Learn more now.

ImageProcessor System.InvalidOperationException


In live site, a lot of http 500 errors are logged from ImageProcessor. The error says "System.InvalidOperationException: Target width 0 and height 0 must be greater than zero." But this is not raised during normal application usage as the image request URL's are correctly formed. Errors are logged from wrongly formed URL's like "|netstat&mode=crop&heightratio=0.5625&quality=80". I noticed the word "netstat" is getting added to the request URL! If I remove "netstat" ,the URL works fine. This malformed URL from unknown source is causing a lot of 500 errors being logged in production. Any help on this?

There are also URL's logged in the format as given below which seems very strange.


May 30, 2023 15:10

Hi Anish,

Have you looked into application insights?

In application insights you should be able to trace the request is causing the 500 error.

By you description of the issue, it sounds like something is rewriting the url, however without logs / telemetry data.

Another probably is that this is an old url and you just need to handle it better.


May 31, 2023 8:07
Anish - May 31, 2023 8:58
Thank you Paul. This exception is logged only in app insights and not visible in application. I noticed that these exceptions logged are not from normal application use. The pages mentioned in the exceptions log they all working fine without any errors. At this point, the source of these requests are unknown. I am not able to reproduce this while normal application use.
Paul McGann (Netcel) - Jun 02, 2023 8:23
Ok, then what I would do instead then is write a global exception handler, within this I would check the exception type is 'InvalidOperationException' and if so log out as much detail as possible to help understand the problem.

If this is happening in you pre-production / integration environments also it might be best to add a check to the code to only log in these environments as in a production environment this may fill up the logs, however you will at least get more information.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.