views:

518

answers:

1

I have a WCF service which is set up to use basic authentication over https like this:

  <basicHttpBinding>
    <binding name="secureTransport">
      <security mode ="Transport">
        <transport clientCredentialType="Basic"/>
      </security>
    </binding>
  </basicHttpBinding>

I have also specified a custom username and password validator. When I call this service from a console application, everything works as expected. However, when I call this service from Silverlight 3, I get a login popup. In both cases, the code is the same and is as follows:

        SecureRemoteBox.Service1Client client = new SecureRemoteBox.Service1Client();
        client.ClientCredentials.UserName.UserName = "test";
        client.ClientCredentials.UserName.Password = "pass";

The client security configuration for the console application is

        <security mode="Transport">
        <transport clientCredentialType="Basic" proxyCredentialType="None" realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>

The client security configuration for the SL3 application is

                <security mode="Transport" />

I have also tried "TransportWithMessageCredential" but with the same issue.

What am I doing wrong? Thanks.

A: 

I'm afraid to say Silverlight 3 doesn't support HTTP Basic Authentication (annoying I know). Best option for authentication is to use asp.net membership provider and check for authentication in your WCF services or pass the username and password as arguments into your services.

HTH

Andy Britcliffe
This MIX 09 presentation seems to suggest it does: http://videos.visitmix.com/MIX09/T42F. Unfortunately, the presenter did not actually do that demo. Also it is listed as a new feature in SL3. Am I mistaken?Thanks.
I'm afraid it doesn't. The only authentication SL3 provides as I mentioned is forms based authentication via cookies. I'm presume they planned to include it but it got cut for RTW
Andy Britcliffe
Well, it does seem to work. The only problem is it pops up the login window asking for the credentials, which I already set in code right before the call. If I enter the same credentials, it works. I want to know how I can get rid of the popup dialog.
Well I'm not sure of you definition of working but from your description it certainly isn't. The popup appears in your browser because the call isn't authenticated simple as. If you're convinced it works....well good luck with it, you'll need it.
Andy Britcliffe