Handle Special Characters in ASP.Net Webservice

When do query page in ASP.NET, the special characters(é,ç,ë etc.,) are comming as ??…

The Response contains both ASCII and non-ASCII characters…

This might be a consequence of the proxy class they generated. It should be able to set the HTTPContentType to “text/xml;charset=utf-8”. This is the header that ‘packs’ the soap, since it is handled by the Microsoft generated proxy class.

Add the following to the main class in each generated Reference.cs:

protected override System.Net.WebResponse GetWebResponse(System.Net.WebRequest request)
   System.Net.WebResponse res = base.GetWebResponse(request);
   res.Headers.Set(“Content-Type”, “text/xml; charset=UTF-8”);
   return res;

This will solve this issue.

Comments are closed.