<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET AJAX Networking and Web Services</title><link>http://forums.asp.net/1009.aspx</link><description>Discuss your issues with the client and server interaction in AJAX using web services and other transports used by AJAX</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Gibberish Returned in Strings from Web Service</title><link>http://forums.asp.net/thread/2631490.aspx</link><pubDate>Fri, 19 Sep 2008 02:33:27 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2631490</guid><dc:creator>bullines</dc:creator><author>bullines</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2631490.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1009&amp;PostID=2631490</wfw:commentRss><description>&lt;p&gt;I managed to find a solution.&amp;nbsp; I neeed to set the ContentEncoding of
the Response to match that of the XML files I was retrieving the
message from (UTF-8):&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;&lt;/pre&gt;&amp;nbsp;&amp;nbsp;&lt;p&gt;Thanks. &lt;/p&gt;</description></item><item><title>Re: Gibberish Returned in Strings from Web Service</title><link>http://forums.asp.net/thread/2619746.aspx</link><pubDate>Sat, 13 Sep 2008 18:13:15 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2619746</guid><dc:creator>bullines</dc:creator><author>bullines</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2619746.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1009&amp;PostID=2619746</wfw:commentRss><description>&lt;p&gt;To add, I&amp;#39;ve noticed that the string only becomes gibberish when it&amp;#39;s returned from a thrown exception.&amp;nbsp; For example, here&amp;#39;s a sample web method in my ASMX:&lt;/p&gt;&lt;pre class="coloredcode"&gt;[ScriptMethod]&lt;br /&gt;[WebMethod]&lt;br /&gt;&lt;span class="kwd"&gt;public string&lt;/span&gt; MyWebMethod(&lt;span class="kwd"&gt;string&lt;/span&gt; input)&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwd"&gt;if&lt;/span&gt; (!ValidInput(input))&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="kwd"&gt;string&lt;/span&gt; l_msg = GetErrorMessage();&lt;br /&gt;        &lt;span class="kwd"&gt;throw new&lt;/span&gt; Exception(l_msg);&lt;br /&gt;    }&lt;br /&gt;    &lt;span class="kwd"&gt;else&lt;br /&gt;        return&lt;/span&gt; input;&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;Back on a web page, I may have something like this:&lt;/p&gt;&lt;pre class="coloredcode"&gt;function GetUserInput()&lt;br /&gt;{&lt;br /&gt;    MyWebServices.MyWebMethod(user_input, OnSuccessCallback, OnFailCallback);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function OnSuccessCallback(result)&lt;br /&gt;{&lt;br /&gt;    $get(&amp;#39;msg_area&amp;#39;).innerHTML = result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function OnFailCallback(error)&lt;br /&gt;{&lt;br /&gt;    $get(&amp;#39;err_msg&amp;#39;).innerHTML = get_message();&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;If the Web Service succeeds and the OnSuccessCallback function is invoked in the client-side JavaScript, any text with characters (such as &amp;quot;ü&amp;quot;, which is ASCII #252), it&amp;#39;s displayed properly - no problem.&amp;nbsp; However, web the Web Service has to throw an exception, thus invoking the OnFailCallback function in the client-side JavaScript, then those same characters are garbled.&amp;nbsp; Is there something I&amp;#39;m missing?&amp;nbsp; Thanks in advance.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Gibberish Returned in Strings from Web Service</title><link>http://forums.asp.net/thread/2604944.aspx</link><pubDate>Sat, 06 Sep 2008 23:08:12 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2604944</guid><dc:creator>bullines</dc:creator><author>bullines</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2604944.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1009&amp;PostID=2604944</wfw:commentRss><description>&lt;p&gt;In my Page_Load() method, I&amp;#39;ve tried:&lt;/p&gt;&lt;pre class="coloredcode"&gt;Response.ContentEncoding = System.Text.Encoding.GetEncoding(&lt;span class="st"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;p&gt;and:&lt;/p&gt;&lt;pre class="coloredcode"&gt;Response.ContentEncoding = System.Text.Encoding.GetEncoding(&lt;span class="st"&gt;&amp;quot;Windows-1252&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;p&gt;But no luck with either. My error messages that I return from my web service are retrieved from XML files that are encoded with UTF-8:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;/pre&gt;&lt;pre class="coloredcode"&gt;&lt;/pre&gt;&lt;p&gt;Is there anything else that I could be missing?&amp;nbsp; Thanks in advance. &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Gibberish Returned in Strings from Web Service</title><link>http://forums.asp.net/thread/2603945.aspx</link><pubDate>Fri, 05 Sep 2008 21:52:14 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2603945</guid><dc:creator>mrmercury</dc:creator><author>mrmercury</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2603945.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1009&amp;PostID=2603945</wfw:commentRss><description>&lt;p&gt;You&amp;#39;ll need to set the encoding with something like:&lt;/p&gt;
&lt;p&gt;Response.ContentEncoding = System.Text.&lt;font color="#2b91af"&gt;Encoding&lt;/font&gt;.GetEncoding(&lt;font color="#a31515"&gt;&amp;quot;iso-8859-1&amp;quot;&lt;/font&gt;);&lt;/p&gt;
&lt;p&gt;In my case iso-8859-1 works great for Spanish special symbols.&lt;/p&gt;</description></item><item><title>Re: Gibberish Returned in Strings from Web Service</title><link>http://forums.asp.net/thread/2603924.aspx</link><pubDate>Fri, 05 Sep 2008 21:33:33 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2603924</guid><dc:creator>bullines</dc:creator><author>bullines</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2603924.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1009&amp;PostID=2603924</wfw:commentRss><description>&lt;p&gt;By &amp;quot;page encoding&amp;quot; are you referring to setting the character set via a manner such as this?&lt;br /&gt;&lt;/p&gt;&lt;pre class="coloredcode"&gt;Response.Charset = &lt;span class="st"&gt;&amp;quot;Windows-1252&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;Thanks in advance.&lt;br /&gt;</description></item><item><title>Re: Gibberish Returned in Strings from Web Service</title><link>http://forums.asp.net/thread/2603869.aspx</link><pubDate>Fri, 05 Sep 2008 20:49:48 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2603869</guid><dc:creator>mrmercury</dc:creator><author>mrmercury</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2603869.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1009&amp;PostID=2603869</wfw:commentRss><description>&lt;p&gt;&lt;span style="FONT-SIZE:11pt;LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;I don´t think there’s a problem with your webmethod; I think you should set the correct encoding of your page so your client can see the special symbols.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Gibberish Returned in Strings from Web Service</title><link>http://forums.asp.net/thread/2603816.aspx</link><pubDate>Fri, 05 Sep 2008 20:23:02 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2603816</guid><dc:creator>bullines</dc:creator><author>bullines</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2603816.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1009&amp;PostID=2603816</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Greetings!&lt;/p&gt;&lt;p&gt;&amp;nbsp;I have a web service (ASMX) and in it, a web method that does some work and throws an exception if the input wasn&amp;#39;t valid.&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;throw new&lt;/span&gt; Exception(l_errMsg ?? &lt;span class="st"&gt;&amp;quot;Invalid Input.&amp;quot;&lt;/span&gt;);&lt;/pre&gt;Back in the client script, on the error callback function, I display my error:&lt;br /&gt;&lt;pre class="coloredcode"&gt;function GetInputErrorCallback(error)&lt;br /&gt;{&lt;br /&gt;    // Insert the error message into the Forgot Password help window&amp;#39;s existing content.&lt;br /&gt;    var errorDiv = document.getElementById(&amp;#39;input_error&amp;#39;);&lt;br /&gt;&lt;br /&gt;    if (errorDiv != null)&lt;br /&gt;        errorDiv.innerHTML = error.get_message();&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This works great.&amp;nbsp; However, if one of my error messages that&amp;#39;s returned contains a special character, it&amp;#39;s displayed incorrectly in the browser.&lt;/p&gt;&lt;p&gt;For example, if the error message were to contain the following:&lt;/p&gt;&lt;p&gt;&lt;b&gt;That input isn’t valid!&lt;/b&gt;&amp;nbsp; (that&amp;#39;s an ASCII #146 in there)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It displays this:&lt;/p&gt;&lt;p style="font-weight:bold;"&gt;That input isnâ€™t valid!&lt;/p&gt;&lt;p&gt;Or:&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight:bold;"&gt;Do you like Hüsker Dü?&lt;/span&gt; (ASCII # 252)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Becomes:&lt;/p&gt;&lt;p style="font-weight:bold;"&gt;Do you like HÃ¼sker DÃ¼?&lt;/p&gt;&lt;p&gt;The values returned by the web service (in the l_errMsg variable) look fine.&amp;nbsp; It&amp;#39;s just once the client script has a hold of, it displays incorrectly.&amp;nbsp; How can I fix this?&amp;nbsp; Thanks in advance.&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>