locked
Silverlight 4 App not Sending Accept-Encoding: gzip, deflate header RRS feed

  • Question

  • I've built a simple Silverlight 4.0 app thats sending an Accept-Encoding: identity header instead of Accept-Encoding: gzip, deflate header. I am using Fiddler to prove this out, and I can see other Silverlight applications that I run on my local machine sending the correct gzip header to their respective services.

    My app is quite simple - just calling into a WCF Data Service to retrieve some data and dump it into a grid. I am setting/passing an Authorization header in the SendingRequest event.

    What could I be doing that would cause this problem. The nature of my WCF service is going to require that I compress the data, and I have also proved out that my server is configured correctly and it will return compressed HTTP data for WCF service calls that do include the gzip header.

    Any ideas what could be wrong?


    Chris
    Saturday, May 29, 2010 12:37 AM

All replies

  • I seem to have nailed this down a little more... I built a simple sample application in Silverlight 3.0 that calls a dummy WCF Data Service. Here's what the HTTP traffic looks like:


    GET http://mycomputer:21701/DataService.svc/Accounts() HTTP/1.1
    Accept-Charset: UTF-8
    Accept-Language: en-us
    dataserviceversion: 1.0;Silverlight
    Accept: application/atom+xml,application/xml
    maxdataserviceversion: 1.0;Silverlight
    Referer: http://mycomputer:21701/Host.aspx
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3)
    Host: mycomputer:21701
    Connection: Keep-Alive

    However, without making any other changes to the project, I upgraded my Silverlight 3.0 project to Silverlight 4.0 and I got this:


    GET http://mycomputer:21701/DataService.svc/Accounts() HTTP/1.1
    Accept: application/atom+xml,application/xml
    Accept-Language: en-US
    Referer: http://localhost:21701/ClientBin/SilverlightApplication1.xap
    Accept-Encoding: identity
    DataServiceVersion: 1.0;NetFx
    MaxDataServiceVersion: 2.0;NetFx
    User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3)
    Host: mycomputer:21701
    Connection: Keep-Alive

    It would seem that by simply upgrading to System.Data.Services.Client.dll from the v3 to v4 version caused me to lose the "Accept-Encoding: gzip, deflate" header. So I'm not sure if I'm missing something, or if there's a bug in the Silverlight 4.0 System.Data.Services.Client.dll...?

    Microsoft - could somebody chime in on this?


    Chris
    Saturday, May 29, 2010 2:25 PM
  • I've now narrowed this down further. It seems that the problem is not related specifically to SL 3 vs. SL 4 upgrades. The problem is actually related to cross-domain access to WCF Data Services. It turns out that my assumption was wrong, and I was fooling myself, because I couldn't use cross-domain access in SL3 but I was in my SL4 tests.

    So, after reading this (http://msdn.microsoft.com/en-us/library/ff650916(VS.95).aspx), it clued me in that the problem might be cross-domain because there's a sentence that says "when the WCF Data Services client detects a cross-domain request, it automatically switches to use the Silverlight client HTTP implementation".

    I can now prove that SL 4 does not send the gzip header on cross-domain calls, but it does in native-domain calls.

    Now, I'm left trying to figure out if its possible to get Silverlight to properly send the Accept-Encoding: gzip, deflate header to a cross-domain service.

    Any ideas?


    Chris
    Saturday, May 29, 2010 5:13 PM