前回に続き今回も調べた内容のメモです。
UWP(ユニバーサルウインドウズプラットフォーム)アプリのWebViewでBasic認証をするにはどうしたらよいのか検索したら、Stack Overflowに答えが載っていました。
具体的には上のリンク先ページにある以下のコードを使うことによって、UWPアプリのWebView上でBasic認証をして"http://website"を表示できます。
var filter = new HttpBaseProtocolFilter(); filter.ServerCredential = new Windows.Security.Credentials.PasswordCredential("http://website","login", "password"); Windows.Web.Http.HttpClient client2 = new Windows.Web.Http.HttpClient(filter); var response = await client2.GetAsync(new Uri("http://website")); WebView.Source = new Uri("http://website");
今ウインドウズ10用のストアアプリが作れないかと試しているので、この方法が見つかって良かったです(^^♪