Silverlight Crossdomain

后端 未结 13 563
面向向阳花
面向向阳花 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:31

    You have to be aware of situation that when you reference to your service inside your project there 'll be created file "Reference.ClienConfig" and there is:

        **
    
    <endpoint address="http://localhost:57675/Servis.asmx" binding="basicHttpBinding"
                bindingConfiguration="ServisSoap" contract="ServiceReference1.ServisSoap"
                name="ServisSoap" />
    

    **

    Make sure that your page is still using the same port (for example here is 57675). By default your localhost 'll get random port, so you have to change it to be static number and not Dynamic. (Right click on asp.net project/Tab Web/Specific port /type number Hope it helps

    0 讨论(0)
  • 2021-01-01 11:32

    Make sure that you put the clientaccesspolicy.xml file in the root of IIS web directory e.g.

    C:\Inetpub\wwwroot\clientaccesspolicy.xml

    This will make sure that it is accessible directly at http:///clientaccesspolicy.xml

    I was getting the same error and I resolved it doing the above steps.

    0 讨论(0)
  • 2021-01-01 11:32

    I modified my Internet explorer settings. The website runs on a intern webserver so I added it in the Iexplorer Trusted Sites list. (Tools->Internet Options->Security->Sites).

    Then I changed the security level and enabled cross domains. Done, Works but took me while to find the solution.

    Best, Jeppen

    0 讨论(0)
  • 2021-01-01 11:33

    I ran into something like this and adding a ServiceHostFactory fixed my issue. The cross-domain policy file alone did not fix it.

    class MyHostFactory : ServiceHostFactory
    {
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            MyHost customServiceHost =
              new MyHost(serviceType, new Uri("[Your URL goes here]",UriKind.Absolute));
    
            return customServiceHost;
        }
    }
    
    class MyHost : ServiceHost
    {
        public MyHost(Type serviceType, params Uri[] baseAddresses)   base(serviceType, baseAddresses)
        { }
    
        protected override void ApplyConfiguration()
        {
            base.ApplyConfiguration();
        }
    }
    

    You also have to add Factory="MyHostFactory" in the tag that defines your service

    0 讨论(0)
  • 2021-01-01 11:35

    Check which project is set default. It should be the web project that should be set default and not the silverlight project.

    0 讨论(0)
  • 2021-01-01 11:36

    Something that worked for me began with what I found on the silverlight forums here. It essentially asked if I could even get to my clientaccesspolicy.xml or crossdomain.xml from localhost (http://localhost/clientaccesspolicy.xml). When I tried to navigate there, I couldn't so I simply found the code for both of them (also within the aforementioned thread), and copy-pasted over the code inside of those files existing in my inetpub\wwwroot\ directory (I opened them up using Notepad++). The weird part was the code didn't change at all , and yet, it works! Hope that helps someone! This was extremely strange.

    clientaccesspolicy.xml

    <?xml version="1.0" encoding="utf-8"?>
     <access-policy>
      <cross-domain-access>
        <policy>
          <allow-from http-request-headers="*">
            <domain uri="*"/>
          </allow-from>
          <grant-to>
            <resource path="/" include-subpaths="true"/>
          </grant-to>
        </policy>
      </cross-domain-access>
    </access-policy>
    

    crossdomain.xml

    <?xml version="1.0"?>
    <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
    <cross-domain-policy>
      <allow-http-request-headers-from domain="*" headers="*"/>
    </cross-domain-policy>
    

    Be blessed!

    -sf

    0 讨论(0)
提交回复
热议问题