Hi everyone, Currently the map services used in my project are not secured, so I want to secure them. I learned some information from ESRI blog that I need to first generate a token for the map service. So I wrote such codes in code-behind.
private void ArcGISDynamicMapServiceLayer_Initialized(object sender, EventArgs e)
{
dynamicServiceLayer =
sender as ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer;
if (dynamicServiceLayer.VisibleLayers == null)
dynamicServiceLayer.VisibleLayers = GetDefaultVisibleLayers(dynamicServiceLayer);
ConfigureLayerWithToken(dynamicServiceLayer);
}
private void ConfigureLayerWithToken(ArcGISDynamicMapServiceLayer layer)
{
string tokenurl =
string.Format("http://rmms-dev.atlas.illinois.edu/ArcGIS/Tokens?request=getToken&username={0}&password={1}&timeout={2}",
username, password, timeout);
var client = new WebClient();
client.DownloadStringCompleted += (sender, e) => { layer.Token = e.Result; };
client.DownloadStringAsync(new Uri(tokenurl));
}
But there is an exception when I run this code. It says: An exception occurred during the operation, making the result invalid. I attach a screenshot for more details. [ATTACH]7273[/ATTACH]Does anyone run into such issue? Or any ideas or thoughts on how to solve this? Thanks a lot!!