Where to place clientaccesspolicy.xml in a Silverlight project

I have a Silverlight application on the client interacting with the server through WCF. Sometimes I get a CommunicationException message - and, in particular, when transferring large amounts of data to some service parameters. I was told that if I want the Silverlight application to communicate with such a server, I need a clientaccesspolicy.xml file to prevent cross-site scripting.

So - I created clientaccesspolicy.xml by default:

<?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>

But now I don’t know where to put it. And I need to tell someone where it is? And - maybe this is the solution to my problems?

+3
source share
1 answer

, clientaccesspolicy.xml, , Silverlight .

, WCF , IIS. IIS, (-).

, .

Windows

, , , . , , , , , WCF . 16 . , , .

<basicHttpBinding>
        <binding name="NewBinding0" maxBufferSize="104857600" maxReceivedMessageSize="104857600">
          <readerQuotas maxDepth="104857600" maxStringContentLength="104857600"
            maxArrayLength="104857600" maxBytesPerRead="104857600" maxNameTableCharCount="104857600" />
        </binding>
      </basicHttpBinding>

.

ServiceReferences.ClienConfig , WCF.

, :

<binding name="ProductConfig" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                  <security mode="None" />
                </binding>

: .

  • web.config " WCF"
  • "Bindings"
  • " "
  • Max * .
  • , , . BindingConfiguration .

web.config,

<system.serviceModel>

<bindings> - . , . , , xml bindingConfiguration = "NewBinding0".

EDIT Take 2:

, , , :

<system.serviceModel>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <extensions>

    </extensions>
    <bindings>
      <basicHttpBinding>
        <binding name="NewBinding0" maxBufferSize="104857600" maxReceivedMessageSize="104857600">
          <readerQuotas maxDepth="104857600" maxStringContentLength="104857600"
            maxArrayLength="104857600" maxBytesPerRead="104857600" maxNameTableCharCount="104857600" />
        </binding>
      </basicHttpBinding>
      <mexHttpBinding>
        <binding name="NewBinding1" />
      </mexHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="policyBehavior">
          <webHttp />
        </behavior>
        <behavior name="NewBehavior" />
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="NewBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="NewBehavior" name="ALMWCFHost.ServiceModel">
        <clear />
        <endpoint address="GuildService" binding="basicHttpBinding" bindingConfiguration="NewBinding0"
          name="ProductConfig" contract="ALMWCFHost.IProductConfigModel"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://omrsrv004/" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>

, , IDE , .

+6

Source: https://habr.com/ru/post/1716753/


All Articles