20 December, 2012

Webservice (asmx) invoke method error after upgrade to .NET 4 (disable compression)

After upgrading some of our old webprojects to .NET 4, we stumbled upon some strange errors when invoking asmx webservice methods. We got all kinds of strange responses back from the server and also on localhost the responses was looking realy strange.

Response in IE9:
"Http 500 Internal Server Error"
The website cannot display the page

Response in Chrome:
This webpage is not found
Error 6 (net::ERR_FILE_NOT_FOUND): The file or directory could not be found.

Response in FireFox:
� ����� �� ` I�%&/m�{J�J��t� �` $ؐ@ ����� iG#)�*��eVe]f @�흼��{���{��;�N'���?\fd l��J�ɞ!��� ?~| ?"^_7m� 7���ݶ�W�/Z�M�YY̲������
�<J��U��˶���:�eˋ���M�U�"���u�^eM:��|��� i;��iY���ֻE�4k��~�/ZW��/,�Ó�n��N�e� � �G��X��3���4M�6�#<V���m],/��`3J�iU�� 
��ʯG o7��պ��i-����wn��l��$zt�nE>K���o����A�X��y}YL�f�ڊ �л� �_f5����<��� ?�<� �[�mW�8��g ���� ?�X?�v�����IU��=5k 7�� ����77�{� ��

We tried debugging the code, but none of the breakpoints was hit, no event log errors, just a strange response from the webserver. So we googled around to see if this was a know bug, but unfortunately not most was found that helped us out, however a lot issues poped up that looked related but in the end was not, apparently not many are upgrading old asmx webservices to a .NET 4 website.

After testing various solutions and combinations of ideas finally we found out that the root bug was hidden for us behind the a response filter that was handling the GZIP/DEFLATE compression of the response. So we disabled the compression on that path/folder and then the root cause was clear, it was the requestValidationMode it needed to be set to: <httpRuntime requestValidationMode="2.0" />

This bug took the most part of a day to fix, so the leason is:
Allways disable HTTP Compression when debugging.

Some reference sources of problem:

No comments:

Post a Comment