SilverLight for security reasons, access to the URL is strictly restricted by default, allowing access only to URL resources under the same child domain.
The following table lists the URL access rules in Silverlight 2.0:
| |
WebClient object |
Media, images, ASX |
XAML file, Font file |
streaming media |
| allowed protocol |
HTTP, http S |
http, https, file |
http, https, file |
http |
| Cross-protocol access |
do not allow |
do not allow |
do not allow |
do not allow access from HTTPS |
| cross-web domain access |
does not allow |
if not from HTTPS allow |
do not allow |
allow |
| Cross-Secure zone access (Windows) |
does not allow |
do not allow |
not allowed |
do not allow |
| Cross-Secure zone access (Macintosh) |
does not allow |
allow |
do not allow |
allow |
| allow redirection |
same domain allow |
allow |
same-domain allow |
do not allow |
If WCF is not on the same site as the Silverlight Web, then we will put two XML file clientaccesspolicy.xml,crossdomain.xml on the root domain of the access side .
Clientaccesspolicy . xml is best saved in utf-8 format, and the contents of the file are as follows:
The content of ClientAccessPolicy.xml
<?xml version= "1.0" encoding= "Utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from>
<domain uri= "*"/>
</allow-from>
<grant-to>
<resource path= "/" include-subpaths= "true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
The crossdomain.xml format is very simple, and its root node is <cross-domain-policy>, which contains one or more <allow-access-from> nodes,< Allow-access-from> has a property domain, which is the value of a field that is allowed to be accessed, an exact IP address, an exact domain, or a wildcard value field (any domain).
Crossdomain.xml Demo
<?xml version= "1.0"?>
<cross-domain-policy>
<allow-access-from domain= "http://www.lishewen.com.cn/"/>
<allow-access-from domain= "*.lishewen.com.cn"/>
<allow-access-from domain= "222.217.221.16"/>
</cross-domain-policy>
For more information on these two files, see MSDN http://msdn.microsoft.com/en-us/library/cc645032 (vs.95). asp Tutorials x