Search code examples
silverlight-4.0wcf-ria-services

Pass a uri to AuthenticationContext


Hey, sorry for my bad english...

I created a new Silverlight Business Application and all is working fine. I have 2 DomainServices, one expose my database objects and another is the default AuthenticationDomainService. The problem is I have to run this services on a different server than the silverlight application... when I create my DomainContext to query data, I use the constructor that accepts a URI specifying the URI to the server, this works but I do not know how to do it for the AuthenticationContext since it's not me who instantiate it (looks like it is automagically created when I access "WebContext.Current.Authentication")... how can I override this and pass the right URI?


Solution

  • In order to use the ctor with URI do the following:

    after creating the web context:

    WebContext webContext = new WebContext();
    webContext.Authentication = new FormsAuthentication();
    this.ApplicationLifetimeObjects.Add(webContext);
    

    set the AuthenticationDomain Context using the URI like this:

    ((WebAuthenticationService)WebContextBase.Current.Authentication).DomainContext = new AuthenticationContext(new Uri(uriPath));