oData服务和Sliverlight压缩 [英] oData Service And Sliverlight Compression

查看:63
本文介绍了oData服务和Sliverlight压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个oData服务,并且在IIS 7服务器中实现了压缩。如果我从Silverlight 4调用该服务,则fiddler中的标题为

I have an oData service and compression is truned on in the IIS 7 Server. If I make a call to the service from Silverlight 4 the header in fiddler is

Accept-Encoding:identity

Accept-Encoding: identity

我该怎么办?将此更改为gzip。在Windows Phone上,我可以在DataServiceContext上使用以下事件,将Accept-Encoding添加到标题中,但这些事件在Silverlight版本的System.Data.Services.Client中不可用

how can I change this to gzip. On the Windows Phone I can use the events below on the DataServiceContext, to add the Accept-Encoding to the header but these events are not avaliable in the Silverlight version of System.Data.Services.Client

WritingRequest + = new EventHandler< ReadingWritingHttpMessageEventArgs>(DataServiceWritingRequest);

ReadingResponse + = new EventHandler< ReadingWritingHttpMessageEventArgs>(DataServiceReadingResponse);

WritingRequest += new EventHandler<ReadingWritingHttpMessageEventArgs>(DataServiceWritingRequest);
ReadingResponse += new EventHandler<ReadingWritingHttpMessageEventArgs>(DataServiceReadingResponse);

谢谢

David。

推荐答案

Hey David,

Hey David,

Silverlight中有一个解决方法。您可以切换堆栈以使用XmlHttp。这将确保在使用silverlight应用程序时它使用浏览器Http堆栈。浏览器将处理gzipped响应。在您进行跨域浏览器请求的情况下,这种解决方法可能无法工作
。出于安全原因,不允许XmlHttp堆栈执行此操作。您将需要连接到sendingEventRequest并指示您希望使用此解决方案进行gzipped响应。

There is a workaround for this in Silverlight. You can switch the stack to use XmlHttp. This will ensure that when the silverlight app is used it uses the browser Http stack. Browsers will take care of the gzipped response. THis workaround might not work in situations where you are making cross domain browser requests though. The XmlHttp stack is not allowed to do this for security reasons. You will need to hook up to the sendingEventRequest and indicate that you want a gzipped response with this solution.

尝试并告诉我其他解决方案是否有效。

Try that and let me know if that solution other works.

谢谢,

Chris Robinson - SDET Odata团队

Chris Robinson - SDET Odata Team


这篇关于oData服务和Sliverlight压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆