I’m using the System.Net.WebClient to retrieve some data from a URL.
void GetAirportData()
{
var url = "http://server.example.com/airports.xml?id=OSL";
var webClient = new WebClient();
webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
webClient.OpenReadAsync(new Uri(url, UriKind.Absolute));
}
void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
//How can I see the original URL here, so that I can see which id parameter was passed?
}
The Requests I send will contain a URL with some parameters that change for each call, and I need to know which parameter I asked for when the reponse comes back.
Can I for instance use the .UserState property of the sender object?
Well, if the URL is required, I’d change your code to something like this: