1

TL;DR Düsseldor is encoded to Düsseldor, Düsseldorf isn't encoded (by the default MVC encoding) why?

I'm building an api with soap access. When I get a request I html encode all the data. Just before I end the current request I copy the Response.Stream and save it for logging.

I noticed that Düsseldorf is encoded by my api to "Düsseldorf". This is expected. But in my logs it shows Düsseldorf encoded as "Düsseldorf" ( double encoded ) my logs saves after the MVC serializes writes to the response stream.

I think this is because soap encodes values before sending them over the wire.

So my next test was to turn off html encoding in my api. So this time Düsseldorf was giving to the soap serializer.

But it was encoded as Düsseldorf?

EDIT: When I say I turn on / off the encoding what I mean is each field in the request I use HttpUtility.HtmlEncode("some field"). And save that to the database. Then I return the data with an MVC view like so:

public ActionResult CreateAccessCode ( CreateAccessCodeRequest request )
{
    var response = new Response (request);
    return new ContentResult (response);
}

My question is when the ContentResult method runs, it seems to do some encoding of its own and I was wondering what that was?

4

1 に答える 1