1

I have a ASP.NET web API running and have a client running into following issue:

{"model":["Unable to translate bytes [E9] 
at index 300 from specified code page to Unicode."]}

The exception appears to be happening during model binding, which is the default nothing custom on my end.

The client is also running .NET and they say that the content is being sent over as UTF16....but they are not including HTTP header to indicate that. Up until they began having special characters in their content everything worked great.

My question is how to deal with this. Initially I was going to add a DelegateHandler which would detect this client and somehow set content-type/charset to UTF16 but that isn't panning out. I then thought I could transcode the request body to UTF8 from within DelegateHandler but have read that modifying content in handler is not possible or recommended.

Since the issue appears to be during model binding I'm wondering if implementing a custom model binder would be in order?

Thanks for any help!

1
  • ...I should also state that client cannot add the header at this point since they've already rolled to production and are experiencing this issue. Commented May 30, 2014 at 15:35

1 Answer 1

3

The default encoding used by the built-in formatters is UTF-8. You can easily change it to UTF 16. You can change this on a per-formatter basis by changing the SupportEncodings property on the MediaTypeFormatter class.

This link can help you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.