How do I _properly_ serve an XAP file from a self-hosted WCF service?

喜欢而已 提交于 2020-01-05 08:45:10

问题


I have myself a self-hosted WCF server setup, which serves a clientaccesspolicy.xml and an index.htm which is just points to my xap (accessible via app.xap).

I'm currently serving them via the following code:

Public Function GetPolicy() As System.IO.Stream Implements IClientAccessPolicy.GetPolicy

    WebOperationContext.Current.OutgoingResponse.ContentType = "application/xml"
    Return New IO.MemoryStream(IO.File.ReadAllBytes("Server Files/ClientAccessPolicy.xml"))

End Function

Public Function GetIndex() As IO.Stream Implements ISilverlightServer.GetIndex

    WebOperationContext.Current.OutgoingResponse.ContentType = "text/html"
    Return New IO.MemoryStream(IO.File.ReadAllBytes("Server Files/index.htm"))

End Function

Public Function GetXap() As IO.Stream Implements ISilverlightServer.GetXap

    WebOperationContext.Current.OutgoingResponse.ContentType = "application/x-silverlight-app"
    Return New IO.MemoryStream(IO.File.ReadAllBytes("Server Files/app.xap"))

End Function

It works, does the job I'm after. However, I don't think this streams the xap properly, and I know it's a streaming type. If this isn't streaming it properly, how should I stream it?

(The endpoint that the XAP and index.htm files are coming through has a webHttpBinding binding)

Is it being streamed properly? Or should I make some changes?


回答1:


That is fine, the XAP file doesn't need to be streamed to the client. Actually, it needs to be first fully downloaded (thus buffered at the client) for the SL application to start, so you don't need to worry about streaming in this case.



来源:https://stackoverflow.com/questions/6322254/how-do-i-properly-serve-an-xap-file-from-a-self-hosted-wcf-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!