2011-03-21 25 views
0

嘿,對不起我的英語不好...通過一個URI到AuthenticationContext

我創建了一個新的Silverlight業務應用程序,並且所有工作都正常。我有2個DomainServices,一個公開我的數據庫對象,另一個是默認的AuthenticationDomainService。問題是我必須在不同於Silverlight應用程序的服務器上運行此服務......當我創建我的DomainContext來查詢數據時,我使用接受指定服務器URI的URI的構造函數,這可行,但我不知道如何爲AuthenticationContext做它,因爲它不是我實例化它(當我訪問「WebContext.Current.Authentication」時它看起來像是自動創建的)...我怎樣才能覆蓋這個並傳遞正確的URI?

回答

1

爲了使用構造函數與URI做到以下幾點:

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

設置使用URI這樣的背景下AuthenticationDomain:

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

創建Web上下文後