我有一个 MVC5 应用程序,我在其中使用 Owin 来验证用户,现在我正在尝试为这个应用程序创建一个 Windows 8 应用程序。但我找不到实施身份验证的最佳原因。我找到了两种可能的解决方案“Web Authentication Broker”和“Credential Locker”,但我还不确定
using (var client = new HttpClient())
{
HttpResponseMessage response = null;
var requestContent = string.Format("UserLogin={0}&UserPassword={1}", userName, password);
HttpContent content = new StringContent(requestContent);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
Task task = Task.Run(async () =>
{
response = await client.PostAsync(new Uri((string)ApplicationData.Current.LocalSettings.Values["LoginApiUrl"]), content);
});
task.Wait(); // Wait
var responseData = await response.Content.ReadAsStringAsync();
var deserializedResponse = JsonConvert.DeserializeObject<Dictionary<string, string>>(responseData);
if (deserializedResponse.ContainsKey("success") && Convert.ToBoolean(deserializedResponse["success"]))
{
LoadData();
}
}