We have seen that all accesses from Silverlight application out of the domain are forbidden by default. However it is necessary to allow accesses from other domains in some situations.
Actually at the access to a resource from other domain, Silverlight Runtime checks if "clientaccesspolicy.xml" file which should be in a root of the given domain exists. If this file is found, parameters of the access to this domain are set in it.
If the file is not found, attempt of search of "crossdomain.xml" file, which is necessary for Adobe Flash applications work, will be made. If both files are not found, the access to the domain is blocked outside.
To understand how it works, let us make some experiments. For this purpose we need to create some websites that work in different domains. For our experiment, such sites can be defined in a "hosts" file which is located in a "%windir %\System32\drivers\etc" folder. For example, it is possible to define this file as follows.
Listing 4 - The "host" file sample
127.0.0.1 site1.com
127.0.0.1 api.site1.com
127.0.0.1 subdomain.api.site1.com
127.0.0.1 site2.com
127.0.0.1 site3.comFrom this listing we can see that we define some domains which refer to local IP-address. It is now necessary to create in some sites in IIS for each of the domains.
Let us place a file "data.xml" on a web-site "api.site1.com" and we will create small Silverlight application which will access this file. There will be some lines of a code which load a XML-file in an asynchronous mode to this application.
Listing 5 - Sample of Silverlight application
private void GetDataButton_Click(object sender, RoutedEventArgs e)
{
var client = new WebClient();
client.DownloadStringCompleted += client_DownloadStringCompleted;
client.DownloadStringAsync(new Uri(ServerURI.Text));
Data.Text = "Loading..";
}
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
Data.Text = e.Result;
}
else
{
Data.Text = "Error: " + e.Error.ToString();
}
}Let us place this application in each domain and try to access to service. Now applications in all domains, except api.site1.com, will throw a SecurityException.
To resolve cross-domain access to "api.site1.com" the domain we will place "clientaccesspolicy.xml" within a web-site "api.site1.com". Thus this file should have the address "http://api.site1.com/clientaccesspolicy.xml". This file has the following format.
Listing 6 - Sample of "clientaccesspolicy.xml" file
Besides, it is possible to adjust the policy so that access is possible from only some domains. For example, the "clientaccesspolicy.xml" file can look as follows.
Listing 7 - Sample of "clientaccesspolicy.xml" file
In other case we can define not only certain domains, but also subdomains.
Listing 8 - Sample of "clientaccesspolicy.xml" file
Also it is possible to limit which port and protocol will be used. For example, we will allow access only via HTTPS for all sites.
Listing 9 - Sample of "clientaccesspolicy.xml" file
Listing 10 - Sample of "clientaccesspolicy.xml" file
In this case cross-domain access is allowed only in case of this header presence.
Listing 11 - Sample of "clientaccesspolicy.xml" file
Slot games with payouts are made easy to understand - OnCasinos
ReplyDeleteIn many cases, 모바일 벳 365 a simple gambling site 바카라양방사무실 can be used for multiple reasons. You 벳 인포 승무패 계산기 can set up your own 12bet slot game, choose your favorite game 김해 휴게텔 from the list of