IIS integrated mode foreign characters

iis-8windows-server-2012

OK so this has been driving us crazy. We have an application built in ASP.NET 4.0 running on Windows Server 2012 and IIS8.

A few pages of our site are translated into multiple languages, notably Japanese and Chinese are the problematic ones.

If we put the application pool to integrated mode – some characters do not display correctly. We're greeted with little question marks.

If we put the application pool in classic mode, all the characters display correctly. Unfortunately this isn't a long-term option for us since it breaks other functionality on the site.

Fun thing – if we change the 'Enable 32-bit applications' setting in Application Pools -> Advanced Settings the pages still display bogus characters however they display different characters incorrectly.

Originally we suspected a bogus character in the page or an encoding problem – but we've quadruple checked everything and verified all the content is utf-8. Switching the application pool to 32-bit and seeing different characters display incorrectly is leading me to think perhaps something is wrong in IIS.

Thanks in advance for any help/insight/experience.

Best Answer

This is a two-parter:

From https://technet.microsoft.com/en-us/library/cc753449%28v=ws.10%29.aspx

"In IIS 7, application pools run in one of two modes: integrated mode and classic mode. The application pool mode affects how the server processes requests for managed code. If a managed application runs in an application pool with integrated mode, the server will use the integrated, request-processing pipelines of IIS and ASP.NET to process the request. However, if a managed application runs in an application pool with classic mode, the server will continue to route requests for managed code through Aspnet_isapi.dll, processing requests the same as if the application was running in IIS 6.0."

https://forums.iis.net/p/1173138/1962242.aspx

Some folks with similar issues had a couple of fixes around forcing IIS 7 to process the character sets the way they wanted. The gist of it is that classic/IIS 6 is accepting the encoding you want to have, but somewhere in the pipeline integrated/IIS 7 is using its default encoding.

This talks about how to set encoding the way you desire: https://stackoverflow.com/questions/9781157/how-to-set-iis-websites-default-encoding

You'll probably want to fiddler/firebug things to see which way it's going (utf8 when it should be ISO-8859-1 or vice versa).

Last but not least, a veritable treatise on how ASP.Net deals with globalization issues: https://support.microsoft.com/en-us/kb/893663. Is for 2.0 but in my experience a lot of stuff like that carries forward to later versions and is probably applicable to 4.0.