我的.NET ASMX web服务正在接受来自客户端的请求,我没有直接控制权。它发送看起来像这样的请求:ASMX Web服务在传入请求中使用错误编码
POST /Service.asmx HTTP/1.1
Connection: Keep-Alive
Pragma: no-cache
Content-Length: 1382
Content-Type: text/xml
Accept: text/xml
Host: localhost
User-Agent: Borland SOAP 1.1
SOAPAction: "http://domain.com/InsertRecords"
<?xml version="1.0"?>
<SOAP-ENV:Envelope... <v>ÄLMÅ BÄCK</v></SOAP-ENV:Envelope>
在我的WebMethod,串ALMA背后被被改写的,以?? ?? LM B ?? CK - 典型的编码混乱。
在我的测试,我发现,如果我只是调整了Content-Type头,一切都很好:
Content-Type: text/xml; charset=utf-8
为什么.NET选择比其他的编码UTF-8时,它的不确定,以及有什么办法可以强制这个ASMX使用UTF-8编码吗?