Silverlight Crossdomain

后端 未结 13 777
面向向阳花
面向向阳花 2021-01-01 10:52

I\'ve seen a lot of links to MSDN and \"works on my machine!\" answers so I\'d like to ask my question with the exact steps to duplicate what I\'m doing. Because we are usin

13条回答
  •  没有蜡笔的小新
    2021-01-01 11:44

    The problem could be that your development server is not able to serve the xml file, try this - explicitly make it available through WebGet

    [ServiceContract]
        public interface ICrossDomainService
        {
            [OperationContract]
            [WebGet(UriTemplate = "ClientAccessPolicy.xml")]
            Message ProvidePolicyFile();
        }
    

    and then the ProvidePolicyFile() can be

    public System.ServiceModel.Channels.Message ProvidePolicyFile()
            {
                FileStream filestream = File.Open(@"ClientAcessPolicy.xml", FileMode.Open);
                // Either specify ClientAcessPolicy.xml file path properly
                // or put that in \Bin folder of the console application
                XmlReader reader = XmlReader.Create(filestream);
                System.ServiceModel.Channels.Message result = Message.CreateMessage(MessageVersion.None, "", reader);
                return result;
            }
    

提交回复
热议问题