do { Engine.BlogAbout(".NET","Silverlight"); } while ( alive );  

Mark Monster

Mark Monster  

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.

4 Responses to “Silverlight 3 – WebClient, WebRequest and WCF calls using Credentials?”

  1. Mark Monster » Blog Archive » Silverlight using WCF with Windows Authentication Says:

    [...] We all know it’s not possible yet to provide credentials when calling WCF Service. I’m telling yet, because I saw some signs that we might get support for credentials. [...]

  2. Silverlight Travel » Silverlight using WCF with Windows Authentication Says:

    [...] We all know it’s not possible yet to provide credentials when calling WCF Service. I’m telling yet, because I saw some signs that we might get support for credentials. [...]

  3. Silverlight 3 – Did we get support for Credentials? « Mark Monster Says:

    [...] A few months ago, I investigated Silverlight 3 Beta on support for Credentials. [...]

  4. Silverlight 4 – Credentials, we’ve got it! « Mark Monster Says:

    [...] March 2009 – Silverlight 3 – WebClient, WebRequest and WCF calls using Credentials? [...]

Leave a Reply