private void LayerWithCredentials(ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer layer)
{
WebClient wmsRequest= new WebClient();
wmsRequest.DownloadStringCompleted += (sender, args) =>
{
map.Layers.Insert(0, layer);
};
ICredentials creds = new NetworkCredential("username", "password");
wmsRequest.Credentials = creds;
wmsRequest.UseDefaultCredentials = true;
wmsRequest.DownloadStringAsync(new Uri(layer.Url));
}
<esri:WmsLayer ID="AGSWMSLayer"
Credentials="{StaticResource MyCredentials}"
Url="http://secured/MapServer/WMSServer"
Initialized="WmsLayer_Initialized"/>
#if !SILVERLIGHT
private System.Net.ICredentials credentials;
/// <summary>
/// Gets or sets the network credentials that are sent to the host and used to authenticate the request.
/// </summary>
/// <value>The credentials used for authentication.</value>
public System.Net.ICredentials Credentials
{
get { return credentials; }
set
{
if (credentials != value)
{
credentials = value;
OnPropertyChanged("Credentials");
}
}
}
#endif