Compartilhar via


Astoria Silverlight Client Failing with FireFox 3.0

Hi all,

By now , anyone running a SIlverlight application Astoria Silverlight Client library in Firefox 3.0 would have seen a weird error about charsets.

This blog post will describe the error and how to work-around it .

Consider the following query :

 DataServiceQuery<Customers> customerQuery = from cus in context.Customers 
                                            where cus.ID =='ALFKI' 
                                            select cus; 

AsyncCallback ac = iasyncResult =>{ 
  DataServiceQuery<Customers> cusQuery = iasyncResult.AsyncState as  DataServiceQuery<Customers>; 
  QueryOperationResponse<Customer>  response = cusQuery.EndExecute(iasyncResult); <-- Exception Thrown here 
}

customerQuery.BeginExecute(ac,customerQuery); 

When this code runs in Firefox 3.0 , the highlighted line throws the exception,

Error Message : Character set 'iso-8859-1' is not supported.

Stack Trace :

   at System.Data.Services.Client.HttpProcessUtility.EncodingFromName(String name)

   at System.Data.Services.Client.HttpProcessUtility.MediaType.SelectEncoding()

   at System.Data.Services.Client.HttpProcessUtility.ReadContentType(String contentType, String& mime, Encoding& encoding)

   at System.Data.Services.Client.DataServiceContext.GetMaterializer(Type elementType, String contentType, Func`1 response, Func`4 create)

   at System.Data.Services.Client.DataServiceRequest.Materialize[TElement](DataServiceContext context, String contentType, Func`1 response)

   at System.Data.Services.Client.DataServiceRequest`1.Materialize(DataServiceContext context, String contentType, Func`1 response)

   at System.Data.Services.Client.DataServiceContext.EndExecute[TElement](IAsyncResult asyncResult)

What is this error ?

When  we recieve the ATOM response from the server , we need to read the stream of content in the charset present in the Accept-charset header. The server does not set the Accept-Charset header and replays what the client sent. The normal Accept-Charset header sent to the server from the SL client looks like this ..

Accept-Charset: UTF-8

Now , in FireFox 3.0 , the Accept-Charset header , even though we explicitly set it to be the above , whats sent to the server is ..

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

And the Server responds back with the same charset and we try to read the content with this char-set.

Unfortunately , the charset ISO-8859-1, is not supported by the underlying Platform i.e SIlverlight.

and hence we error out

How do I fix this for now ?

Follow these instructions on changing your browser settings to work around the issue

  1. Type about:config in the Firefox browser's address bar.
  2. Navigate through a dialog box and check “I’ll be careful”.
  3. In the Page’s Search box , type : “intl.charset.default” .
  4. Double click on the entry  that turns up , and set the value to “utf-8” .

Hope this helps.If you still face problems , open a thread on the Astoria Forums and we will try to help out.

Comments