Silverlight 3 – WebClient, WebRequest and WCF calls using Credentials?

It’s already a long time ago I wrote some articles about the missing feature of passing credentials while doing a WebRequest, WebClient or WCF call. We now have ourselves Silverlight 3 Beta, it looks like we’re getting support for Credentials at last. I can now write the following code which is seen as valid. It compiles as well…
var webClient = new WebClient();
webClient.Credentials =
    new NetworkCredential("Administrator", "p@ssw0rd");
webClient.DownloadStringCompleted +=
    webClient_DownloadStringCompleted;
webClient.DownloadStringAsync(
    new Uri("SomeData.xml", UriKind.Relative));
But does it work? Not yet, sadly. Right now we will get an exception… image The inner exception is a NotImplementedException.
{System.NotImplementedException: This property is not implemented by this class.
   at System.Net.WebRequest.set_Credentials(ICredentials value)
   at System.Net.WebClient.GetWebRequest(Uri address)
   at System.Net.WebClient.DownloadStringAsync(Uri address, Object userToken)}
What does this mean? We don’t know anything yet. The only thing we can do is speculate about a feature coming in Silverlight 3, Credentials for WebRequests. I could find the usage of ICredentials inside WebRequest and WebClient. It’s not near implementation in WCF Clients yet, but we can hope for this to be implemented as well. Ps. This article is cross posted on: Mark Monster’s blog and Silverlight Help.
Gravatar