私はOdataサービスとWPFクライアントアプリケーションを持っています。 一部のOdataサービスエンティティには、画像が添付されています(つまり、クライアント)。データサービス認証がserviceContext.GetReadStreamUri(..)と連携していません
私が認証を適用しない限り、ストリーミングは機能します。私は画像を見て変更することができます。認証を実施すると、資格情報のチェックアウトが行われると、すべてが期待通りに機能します。イメージを除くすべてのもの。関連するコードステップ/スナイプを以下に示します。
ウィンドウコンストラクタコード
bool iv = System.Web.Security.Membership.ValidateUser("userName", "pass");
ManageService = new InventoryContext(new Uri(...));
ManageService.SendingRequest += new EventHandler<SendingRequestEventArgs (ManageService_SendingRequest);
ManageService_SendingRequestコード
//attach the authentication cookie to the request header
((HttpWebRequest)e.Request).CookieContainer = ((ClientFormsIdentity)Thread.CurrentPrincipal.Identity).AuthenticationCookies;
データをバックグラウンドワーカー クエリMethodeの()
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(FetchClient);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(FetchClientsCompleted);
worker.RunWorkerAsync(ClientUUID);
FetchClient
を使用して非同期(async)でフェッチするコールvar query = from o in ManageService.Clients where o.ClientUUID.Equals((Guid)e.Argument)
...
e.Result = query;
var res = e.Result as DataServiceCollection<Client>;
DataContext = res[0]; //this is all working, with and without authentication
//the next line, binding the stream to the image throws 'unauthenticated'
//it works well if authentication is disabled
imgClient.Source = new BitmapImage(ManageService.GetReadStreamUri(DataContext));
をFetchClientsCompleted私はデバッグする場合、通常、任意のクエリ要求と呼ばれるSendingRequestのMethodeのは、GetReadStreamUri(...)を呼び出してトリガされません。 これは私が立ち往生している場所です。ストリームを取得するためにサービスを認証するために何をすべきですか?
また、私はブラウザにそれを過ぎて、ManageService.GetReadStreamUri(DataContextの)によって生成されたURIを取り、それがログインしている場合、画像は、ブラウザに表示されている。
誰でも任意のアイデアを作品?
Thanx Vitek Karas MSFT、 – Andreas
Thanx @Vitek、私は最初の部分を理解していますが、私は要求を自分自身で発行することが何であるか分かりません。 GetREadStreamUri()の代わりにGetReadStream()を使うべきですか? – Andreas
GetReadStreamも同様に動作します。 –