IIS7 Error: No mapping for the Unicode character exists in the target multi-byte code page

1

I have a problem when a url contains Chinese characters. It doesn't happen every time, but when it does, I find the following errors in the event log:

EventMessage
    No mapping for the Unicode character exists in the target multi-byte code page. (Exception from HRESULT: 0x80070459) 
EventStackTrace
    System.ArgumentOutOfRangeException: No mapping for the Unicode character exists in the target multi-byte code page. (Exception from HRESULT: 0x80070459)
    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
    at System.Web.Hosting.IIS7WorkerRequest.GetServerVariableInternal(String name)
    at System.Web.Hosting.IIS7WorkerRequest.GetServerVariable(String name)
    at System.Web.Hosting.IIS7WorkerRequest.ReadRequestHeaders()
    at System.Web.Hosting.IIS7WorkerRequest.GetKnownRequestHeader(Int32 index)
    at System.Web.HttpRequest.FillInHeadersCollection()
    at System.Web.HttpRequest.get_Headers()

It seems the exception was thrown in the native method.

asp.net
iis-7
unicode
asked on Stack Overflow Nov 9, 2011 by Heclei • edited Nov 9, 2011 by competent_tech

2 Answers

2

It seems like this happens when a Cookie or other header contains a unicode character. This blog entry may shed some light on the problem and a solution.

answered on Stack Overflow Nov 9, 2011 by competent_tech
-1

I solved it by send data as Base64String, in my case it is an object:

byte[] bytes = Encoding.UTF8.GetBytes(Json.Convert(myObject))
client.DefaultRequestHeaders.Add("data" , Convert.ToBase64String(bytes));
answered on Stack Overflow Jul 28, 2020 by Emanuel Adler • edited Jul 28, 2020 by סטנלי גרונן

User contributions licensed under CC BY-SA 3.0