2
votes

Web Link

Problem:

On Azure Web App Service, sometime get Character �(#65533), but then things go back to normal,they're same page and it is normal under local iis server.

character �(#65533) version:

...這���種假物件...

normal version:

...這兩種假物件...

Environment :

Web.Config : <globalization requestEncoding="utf-8" responseEncoding="utf-8" />

Server : Microsoft-IIS/10.0,Asp.NET 4.5.2

FrameWork : BlogEngine.NET

My Question:

Is it Azure problem or some one azure setting?

1

1 Answers

2
votes

I think it related to BlogEngine.NET implementation. In CompressionModule.cs#L189, it configured a WebResourceFilter into context.Response.Filter. That's the root cause of this problem.

You can check the WebResourceFilter.cs file. The Write() method do have problem:

public override void Write(byte[] buffer, int offset, int count)
{
    // collect all HTML in local variable
    var html = Encoding.UTF8.GetString(buffer, offset, count);
    HtmlOut += html;
}

The buffer size is not guarantee. If the buffer split in the middle of the UTF-8 character (which Chinese characters in UTF-8 is multi-bytes). It's impossible to get the right string in UTF8. So you will get the messy characters you mentioned.

There is also an exact issue here: https://github.com/rxtur/BlogEngine.NET/issues/91